<?php

class showController extends base
{

    public function __construct()
    {
        parent::__construct('show');
        $this->redisKeyBase=REDIS_PREFIX.'gear_';
        $this->redisCache = $this->in_redis('cacheRedis');
        $this->view->assign('staticVersion',37);
    }

    public function dopy()
    {
        $wxConfig = $this->loadLib('weixinPub')->getWxConfig();
        $this->view->assign('wxConfig', $wxConfig);
        $this->view->display('show/py');
    }

    /**
     * 点融网活动跳转链接
     */
    public function dodr()
    {
        $token = common::request('token');

        if(empty($_SERVER['HTTP_USER_AGENT']) || stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger'))
        {
            if(!empty($_COOKIE['joggers_u']))
            {
                setcookie('joggers_u', ' ', time()-864000, '/', '.hupu.com', FALSE, TRUE);
                setcookie('joggers_u', ' ', time()-864000, '/', '.ijoggers.com', FALSE, TRUE);
            }
        }
        else
        {
            if($token && empty($_COOKIE['joggers_u']))
            {
                setcookie('joggers_u', $token, time()+864000, '/', '.hupu.com', FALSE, TRUE);
                setcookie('joggers_u', $token, time()+864000, '/', '.ijoggers.com', FALSE, TRUE);
            }
        }

        common::go('http://dianrong.hupu.com');
    }

    /**
     * 贵人鸟活动跳转链接
     */
    public function dogrn()
    {
        $token = common::request('token');

        if(empty($_SERVER['HTTP_USER_AGENT']) || stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger'))
        {
            if(!empty($_COOKIE['joggers_u']))
            {
                setcookie('joggers_u', ' ', time()-864000, '/', '.hupu.com', FALSE, TRUE);
            }
        }
        else
        {
            if($token && empty($_COOKIE['joggers_u']))
            {
                setcookie('joggers_u', $token, time()+864000, '/', '.hupu.com', FALSE, TRUE);
            }
        }

        common::go('http://grnhalotime.hupu.com');
    }

    public function donews()
    {
        $this->load('client');
        $news_id = common::request('news_id', 'G');
        $news_id = intval($news_id);

        $bbs_mod = $this->load('bbs');
        $newsInfo = $bbs_mod->getPostInfo($news_id);
        if(empty($news_id) || empty($newsInfo) || time() < $newsInfo['add_time'] || (isset($newsInfo) && $newsInfo['is_show']==0))
        {
            $rUrl = 'http://run.hupu.com/mobile?r=404';
            header('Location: ' . $rUrl);
            exit();
        }
        // 处理帖子内容
        if(isset($newsInfo['type']) && $newsInfo['type'] == 0)
        {
            //$newsInfo['content'] = $_ENV['bbs']->buildPostContent($newsInfo['content'], $newsInfo['sourceImg']);
            $newsInfo['content'] = preg_replace("/<img[^>]+>/", "", $newsInfo['content']);
        }

        preg_match_all('/(<a href="joggers:\/\/profile\/\d+">.*<\/a>)/U', $newsInfo['content'], $matches);
        if(!empty($matches[1]))
        {
            foreach ($matches[1] as $str) {
                $newsInfo['content'] = preg_replace('/<a href="joggers:\/\/profile\/\d+">(.*)<\/a>/U', '<strong>@${1}</strong> ', $newsInfo['content']);
            }
        }
        $newsInfo['content'] = str_replace('joggers://topic/image/', '', $newsInfo['content']);
        $newsInfo['content'] = $bbs_mod->buildWidget($newsInfo['content'],$news_id,3);
        $time = time() - $newsInfo['add_time'];
        $publishTime = date('Y-m-d H:i:s');
        $hotComment = $this->load('bbs')->getCommentList($news_id,0,'next',4);
        $likeNum = $this->redis->zcard(REDIS_PREFIX.'PostLikeList_'.$news_id);
        $likeList = $this->load('bbs')->getPostLikeList($news_id, 0, 'next', 8);


        $this->view->assign('likeNum', $likeNum);
        $this->view->assign('likeList', $likeList);
        $this->view->assign('publishTime', $publishTime);
        $this->view->assign('commentCount', $newsInfo['total_comment']);
        $this->view->assign('hotComment', $hotComment);
        $this->view->assign('newsInfo', $newsInfo);
        $this->view->display('show/share_bbs');
    }
    /*
     * 怎么玩页面 （跑步等级和正能量说明）
     */
    public function dohowToPlay()
    {
        $this->view->display('howToPlay');
    }

    /*
     * 分享好友排行榜
     */
    public function doshareStandings()
    {
        $uid = common::request('uid', 'G', 0);
        $uid = intval($uid);

        $userInfo = $this->load('client')->getUserInfo($uid);
        if(empty($uid) || empty($userInfo))
        {
            $rUrl = 'http://run.hupu.com/mobile?r=404';
            header('Location: ' . $rUrl);
            exit();
        }
        $isAppInstalled = -1;
        if(isset($_SERVER['HTTP_USER_AGENT']) && stristr($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== FALSE)
        {
            // 是否已安装 虎扑跑步 app，微信会自动传递此参数
            $isAppInstalled = common::request('isappinstalled', 'G');
            $isAppInstalled = intval($isAppInstalled) ? 1 : 0;
            /*
            if($isAppInstalled == 1)
            {
                setcookie('_joggersInstalled', 1, time() + 6048000, '/', 'hupu.com', FALSE, TRUE);
            }
            else
            {
                $isAppInstalled = common::request('_joggersInstalled', 'C');
            }
            */
        }
        else
        {
            $isAppInstalled = common::request('isappinstalled', 'G', -1);
            in_array($isAppInstalled, array(0,1)) && $isAppInstalled += 2;
        }
        $rank = $this->load('friends')->getMyMilRankInFriends($uid,REDIS_PREFIX .'friendMilStangdsmonth'.date("n").'_'.$uid, $uid);
        $friendsCount = $this->redis->zcard(REDIS_PREFIX.'Friends_'.$uid);
        $fight = $friendsCount == 0 ? 0 :($friendsCount-$rank);
        $words = '';
        $runImg = '../static/backend/invite/invite_words01.png';
        if($friendsCount == 0)
        {
            $runImg = '../static/backend/invite/invite_words03.png';
        }
        else
        {
            $words = '<p>我已在虎扑跑步</p><p>战胜 <strong>'.$fight.'</strong> 名好友</p>';
            $runImg = '../static/backend/invite/invite_words02.png';
        }

        $this->view->assign('isShare', 1);
        $this->view->assign('userInfo', $userInfo);
        $this->view->assign('isAppInstalled', $isAppInstalled);
        $this->view->assign('words', $words);
        $this->view->assign('runImg', $runImg);
        $this->view->display('inviteFriends');
    }
    /*
     * 邀请好友
     */
    public function doinvite()
    {
        $uid = common::request('uid', 'G', 0);
        $uid = intval($uid);
        $userInfo = $this->load('client')->getUserInfo($uid);
        if(empty($uid) || empty($userInfo))
        {
            $rUrl = 'http://run.hupu.com/mobile?r=404';
            header('Location: ' . $rUrl);
            exit();
        }

        $isAppInstalled = -1;
        if(isset($_SERVER['HTTP_USER_AGENT']) && stristr($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== FALSE)
        {
            // 是否已安装 虎扑跑步 app，微信会自动传递此参数
            $isAppInstalled = common::request('isappinstalled', 'G');
            $isAppInstalled = intval($isAppInstalled) ? 1 : 0;
            /*
            if($isAppInstalled == 1)
            {
                setcookie('_joggersInstalled', 1, time() + 6048000, '/', 'hupu.com', FALSE, TRUE);
            }
            else
            {
                $isAppInstalled = common::request('_joggersInstalled', 'C');
            }
            */
        }
        else
        {
            $isAppInstalled = common::request('isappinstalled', 'G', -1);
            in_array($isAppInstalled, array(0,1)) && $isAppInstalled += 2;
        }
        $friendsCount = $this->redis->zcard(REDIS_PREFIX.'Friends_'.$uid);
         $words = $friendsCount == 0 ? '<p>一个人跑步木有动力</p><p>快快加入虎扑跑步，我们相互监督、相互PK！</p>':'<p>我已在虎扑跑步 <strong>'.$userInfo['total_rate'].'</strong> 次</p><p>总距离 <strong>'.$userInfo['total_mileage'].'</strong> km</p><p>快快加入，和我一决高下吧！</p>';


        $runImg = '/static/backend/invite/intvite_words0' . ($friendsCount == 0 ? '3' : '2') . '.png';

        $this->view->assign('url', 'joggers://invite/'.$uid);
        $this->view->assign('isShare', 0);
        $this->view->assign('userInfo', $userInfo);
        $this->view->assign('isAppInstalled', $isAppInstalled);
        $this->view->assign('runImg', $runImg);
        $this->view->assign('words', $words);
        $this->view->display('inviteFriends');

    }
    /*
     * 调起虎扑跑步
     */
    public function doinvokeMe()
    {
        $redirect=common::request("redirect", 'G');
        empty($redirect) && $redirect = 'http://mobile.hupu.com/download/joggers?r=share';

        $this->view->assign('redirect', $redirect);
        $this->view->display('invokeMe');
    }
    /*
     * 虎扑服务协议
     */
    public function doprivacy()
    {
        $this->view->display('privacy');
    }
    public function docheckUser()
    {
        $is = 0;  // 设备号是否对应
        $userId = 0;

        $token = common::request('token','G','');
        $client = common::request('client','G','');
        $num = common::request('num','G','');
        $timestamp = common::request('timestamp','G','');
        $sign = common::request('sign','G','');

        if(!empty($token) && !empty($client) && !empty($num) && !empty($timestamp) && !empty($sign) && $sign == md5($token . "lottery" . $num . "hoopchina" . $client . "running2015".$timestamp."WmChina3WhoopZYTPz0wzccnWSS"))
        {
            $tokenArr = explode('-', $token);
            $uid = $tokenArr[0];
            $time = isset($tokenArr[1]) ? intval($tokenArr[1]):'';
            $md5Str = isset($tokenArr[2]) ? trim($tokenArr[2]):'';
            $clientHash = isset($tokenArr[3]) ? trim($tokenArr[3]):'';

            if($clientHash && strlen($clientHash) == 32)
            {
                $uid = $this->alphaId->getNumber($uid);
            }

            $uid = intval($uid);

            if(md5($uid.$time.$this->config['tokenStr']) == $md5Str)
            {
                if($this->redis->exists(REDIS_PREFIX.'UserInfo_'.$uid))
                {
                    $userId = $uid;
                    $cid = $this->redis->hget(REDIS_PREFIX.'ClientCid', $client);
                    $lastcid = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$uid, 'lastcid');
                    $usercid = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$uid, 'cid');
                    $lastcid = $lastcid > 0 ? $lastcid : $usercid;
                    $is = $cid == $lastcid ? 1 : 0;
                }
            }
        }
        $result = json_encode(compact('userId','is'));
        exit($result);
    }
    /*
     * BMI和体质率说明
     */
    public function dobmiinfo()
    {
        $this->view->display('bmiinfo');
    }
     public function dofatinfo()
    {
        $this->view->display('bmiinfo-fat');
    }
    /*
     * 邀请群成员
     */
    public function dogroupinvite()
    {
        $gid = common::request('GroupID', 'G', 0);
        $uid = common::request('uid', 'G', 0);
        $r = common::request('r', 'G', '');
        $gid = intval($gid);
        $uid = intval($uid);

        $ginfo = $this->load('group')->getGroupInfo($gid);

        if(empty($ginfo) || (isset($ginfo['isDismiss']) && $ginfo['isDismiss'] == 1))
        {
            $rUrl = 'http://run.hupu.com/mobile?r=404';
            header('Location: ' . $rUrl);
            exit();
        }
        $group = array('gid'    => $gid,
                       'name'   => $ginfo['name'],
                       'header'   => $ginfo['header'],
                       'addtime'=> date("Y年n月j日", $ginfo['addtime'])
                    );
        $host = $this->redis->hget(REDIS_PREFIX.'GroupHost', $gid);
        $group['hostName'] = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$host, 'nickname');
        $group['citys'] = $this->db->getone("select count(distinct(city)) from r_group_run where gid = '{$gid}'");
        $group['times'] = $this->db->getone("select count(*) from r_group_run where gid = '{$gid}'");
        $group['total_mileage'] = $this->load('group')->getGroupRunTotal($gid);
        $group['inviteUrl'] = 'joggers://Groupinfo/'.$gid;

        $isAppInstalled = -1;
        if(isset($_SERVER['HTTP_USER_AGENT']) && stristr($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== FALSE)
        {
            // 是否已安装 虎扑跑步 app，微信会自动传递此参数
            $isAppInstalled = common::request('isappinstalled', 'G');
            $isAppInstalled = intval($isAppInstalled) ? 1 : 0;
        }
        else
        {
            $isAppInstalled = common::request('isappinstalled', 'G', -1);
            in_array($isAppInstalled, array(0,1)) && $isAppInstalled += 2;
        }

        $this->view->assign('group', $group);
        $this->view->assign('sImg', 'http://hupu-run.qiniudn.com/Joggers.png.png');
        $this->view->assign('shareurl', 'http://'.$this->config['host'].'/show/groupInvite?GroupID='.$gid.'&r=wxshare');
        $this->view->assign('shareTitle', '我加入了虎扑跑步群组【'.$ginfo['name'].'】，群组号：'.$ginfo['gid'].'，邀请你加入我们，从现在出发！');
        $this->view->assign('staticHost', $this->config['img-host']);
        $this->view->assign('isAppInstalled', $isAppInstalled);
        $this->view->display('groupInvite');
    }
    /*
     * 群记录
     */
    public function dogroupday()
    {
        $gid = common::request('GroupID', 'G', 0);
        $date = common::request('Day', 'G', '');
        $r = common::request('r', 'G', '');

        $gid = intval($gid);

        $ginfo = $this->load('group')->getGroupInfo($gid);
        if(empty($ginfo) || (isset($ginfo['isDismiss']) && $ginfo['isDismiss'] == 1))
        {
            $rUrl = 'http://run.hupu.com/mobile?r=404';
            header('Location: ' . $rUrl);
            exit();
        }
        $group = array('gid'    => $gid,
                       'name'   => $ginfo['name']
                       );
        $time = strtotime($date);
        !$time && $time = time();
        $group['y'] = date("Y", $time);
        $group['m'] = date("n", $time);
        $group['d'] = date("j", $time);
        $endTime = $time + 86399;
        $runStatitistic = $this->db->getRow("select count(distinct(uid)) as totalUser, sum(mileage) as total_mileage from r_group_run where gid = '{$gid}' and updatetime >= '{$time}' and updatetime < '{$endTime}'");
        $group = array_merge($group, $runStatitistic);
        !$group['total_mileage'] && $group['total_mileage'] = 0;
        $dayBest = array();
        $earliest = $this->db->getRow("select did, uid, mileage from r_group_run where gid = '{$gid}' and updatetime >= '{$time}' and updatetime < '{$endTime}' order by updatetime ASC limit 1");
        $farthest = $this->db->getRow("select did, uid, mileage from r_group_run where gid = '{$gid}' and updatetime >= '{$time}' and updatetime < '{$endTime}' order by mileage DESC limit 1");
        $longest = $this->db->getRow("select did, uid, mileage from r_group_run where gid = '{$gid}' and updatetime >= '{$time}' and updatetime < '{$endTime}' order by elapsedtime DESC limit 1");
        $type = array('earliest' => '早起鸟', 'farthest' => '跑步最远', 'longest' => '跑步最久');
        $dids = array();
        foreach ($type as $k => $v) {
            if(empty($$k))
            {
                continue;
            }
            $value = $$k;
            $value['title'] = $v;
            $value['nickname'] = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$value['uid'], 'nickname');
            $value['header'] = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$value['uid'], 'header');
            $value['loves'] = $this->load('run')->getRunRecordLikes($value['did'], $gid);
            $dayBest[$k] = $value;
            $dids[] = $value['did'];
        }
        $dbIn = $this->load('push')->db_create_in($dids);
        $runList = $this->db->getAll("select did, uid, mileage from r_group_run where gid = '{$gid}' and updatetime >= '{$time}' and updatetime < '{$endTime}' and did not ".$dbIn." order by did DESC");
        if(!empty($runList))
        {
            foreach ($runList as & $value) {
                $value['nickname'] = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$value['uid'], 'nickname');
                $value['header'] = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$value['uid'], 'header');
                $value['loves'] = $this->redis->ZCARD(REDIS_PREFIX.'RunLike_'.$value['did']);
            }
        }
        else {
            $runList = NULL;
        }

        $this->view->assign('group', $group);
        $this->view->assign('dayBest', $dayBest);
        $this->view->assign('runList', $runList);
        $this->view->assign('nullBest', empty($dids));
        $this->view->assign('staticHost', $this->config['img-host']);
        $this->view->display('groupDay');
    }
    /*
     * 周报
     */
    public function dogroupweek()
    {
        $gid = common::request('GroupID', 'G', 0);
        $date = common::request('date', 'G', '');
        $r = common::request('r', 'G', '');

        $gid = intval($gid);

        $ginfo = $this->load('group')->getGroupInfo($gid);
        if(empty($ginfo) || (isset($ginfo['isDismiss']) && $ginfo['isDismiss'] == 1))
        {
            $rUrl = 'http://run.hupu.com/mobile?r=404';
            header('Location: ' . $rUrl);
            exit();
        }
        // 数据总览
        $all = array();
        $bestRecord = array();
        $rankings = array();
        $topThree = array();

        $all['name'] = $ginfo['name'];
        $time = strtotime($date);
        !$time && $time = time();
        $all['year'] = date("Y", $time);
        $all['week'] = date("W", $time);
        $start = strtotime($all['year'].'-W'.$all['week']);
        $end = $start + 7*86400 -1;

        $all['dateRange'] = date("Y-n-j", $start).' ~ ' .date("Y-n-j", $end);

        $weekth = $all['year'].$all['week'];
        $month = date("Y-m", $time);
        $GTarget = $this->load('group')->getGroupTarget($gid, $month);
        empty($GTarget) && $GTarget = 0;
        $all['GTarget'] = $GTarget;
        $all['GRate'] = $GTarget == 0 ? NULL : round($this->load('group')->getGroupRunMoWTotal($gid,$month)/$GTarget, 3); // 群组月目标完成度
        $all['GRate'] = sprintf("%.1f%%", $all['GRate']*100);
        $all['totalRun'] = $this->load('group')->getGroupRunMoWTotal($gid,$weekth); // 群组周跑量
        $runStatitistic = $this->db->getRow("select count(distinct(uid)) as totalUser, count(*) as times from r_group_run where gid = '{$gid}' and updatetime >= '{$start}' and updatetime < '{$end}'");
        $all = array_merge($all, $runStatitistic);
        // 最佳记录
        $bestRecord = $this->load('group')->getBestRecord($gid);
        if($bestRecord)
        {
            foreach ($bestRecord as & $v) {
                $v['nickname'] = $this->load('bbs')->cutString($v['nickname'], 15);
            }
        }
        $rankings = $this->load('group')->getGMRank($gid, common::getWeekth($start));
        empty($rankings) && $rankings = array();
        for($i = 0; $i<3; $i++)
        {
            $key = $i == 0 ? 'one' : ($i == 1 ? 'two' : 'three');
            if(isset($rankings[$i]))
            {
                $topThree[$key] = $rankings[$i];
                unset($rankings[$i]);
            }
            else
            {
                $topThree[$key] = array('uid' => '0',
                                        'nickname' => '',
                                        'header' => $this->config['img-host'].'img/user_header.png',
                                        'mileage' => '0',
                                        'level' => '1',
                    );
            }
        }

        $this->view->assign('all', $all);
        $this->view->assign('bestRecord', $bestRecord);
        $this->view->assign('topThree', $topThree);
        $this->view->assign('rankings', $rankings);
        $this->view->assign('type', 'week');
        $this->view->assign('staticHost', $this->config['img-host']);

        $this->view->display('groupReport');
    }
    /*
     * 月报
     */
    public function dogroupmonth()
    {
        $gid = common::request('GroupID', 'G', 0);
        $date = common::request('date', 'G', '');
        $r = common::request('r', 'G', '');

        $gid = intval($gid);
        $ginfo = $this->load('group')->getGroupInfo($gid);
        if(empty($ginfo) || (isset($ginfo['isDismiss']) && $ginfo['isDismiss'] == 1))
        {
            $rUrl = 'http://run.hupu.com/mobile?r=404';
            header('Location: ' . $rUrl);
            exit();
        }
        // 数据总览
        $all = array();
        $bestRecord = array();
        $rankings = array();
        $topThree = array();

        $all['name'] = $ginfo['name'];
        $time = strtotime($date);
        !$time && $time = time();
        $all['year'] = date("Y", $time);
        $all['month'] = date("n", $time);
        $month = date("Y-m", $time);
        $start = $time;
        $end = strtotime("$month +1 month") -1;
        $all['GTarget'] = $this->load('group')->getGroupTarget($gid, $month); // 群组月目标
        empty($all['GTarget']) && $all['GTarget'] = 0;
        $all['GRate'] = $all['GTarget'] == 0 ? NULL : round($this->load('group')->getGroupRunMoWTotal($gid,$month)/$all['GTarget'], 3); // 群组月目标完成度
        $all['GRate'] = sprintf("%.1f%%", $all['GRate']*100);
        $all['totalRun'] = $this->load('group')->getGroupRunMoWTotal($gid,$month); // 群组月跑量
        $runStatitistic = $this->db->getRow("select count(distinct(uid)) as totalUser, count(*) as times from r_group_run where gid = '{$gid}' and updatetime >= '{$start}' and updatetime < '{$end}'");
        $all = array_merge($all, $runStatitistic);
        // 最佳记录
        $bestRecord = $this->load('group')->getBestRecord($gid);
        if($bestRecord)
        {
            foreach ($bestRecord as & $v) {
                $v['nickname'] = $this->load('bbs')->cutString($v['nickname'], 15);
            }
        }
        $rankings = $this->load('group')->getGMRank($gid, date("Y-m", $start));
        empty($rankings) && $rankings = array();
        for($i = 0; $i<3; $i++)
        {
            $key = $i == 0 ? 'one' : ($i == 1 ? 'two' : 'three');
            if(isset($rankings[$i]))
            {
                $topThree[$key] = $rankings[$i];
                unset($rankings[$i]);
            }
            else
            {
                $topThree[$key] = array('uid' => '0',
                                        'nickname' => '',
                                        'header' => $this->config['img-host'].'img/user_header.png',
                                        'mileage' => '0',
                                        'level' => '1',
                    );
            }
        }
        $this->view->assign('all', $all);
        $this->view->assign('bestRecord', $bestRecord);
        $this->view->assign('topThree', $topThree);
        $this->view->assign('rankings', $rankings);
        $this->view->assign('type', 'month');
        $this->view->assign('staticHost', $this->config['img-host']);

        $this->view->display('groupReport');
    }

    //集合
    public function dogearSet()
    {
        $gid = common::request('sid');
        $gid = intval($gid);

        $this->in_user();
        $sets = $this->load('gear')->getGearSetInfoByGid($gid);
        $isInAppWebview = common::isInAppWebview();

        if($sets)
        {
            $sets['is_like'] = 0;

            if($this->uid)
            {
                $redisKey = REDIS_PREFIX . 'GearSetLike_' . $gid;
                $sets['is_like'] = $this->redis->sismember($redisKey, $this->uid) ? 1 : 0;
            }

            $gids = explode(',', $sets['relate_content']);
            $list = $_ENV['gear']->getGearInfo($gids);
        }
        else
        {
            exit;
        }

        $left = array();
        $right = array();

        foreach($list as $k => $v)
        {
            if(!$v)
            {
                unset($list[$k]);
                continue;
            }
        }

        $list = array_values($list);

        foreach($list as $k => $v)
        {
            $v['img'] = !empty($v['images'][0]) ? $v['images'][0] : '';

            if($k % 2 == 0)
            {
                $left[] = $v;
            }
            else
            {
                $right[] = $v;
            }
        }

        $this->view->assign('isInAppWebview',$isInAppWebview);
        $this->view->assign('left',$left);
        $this->view->assign('right',$right);
        $this->view->assign('set',$sets);
        $this->view->display('show/set');

    }

    /**
     * 装备首页(2.5.5+)
     */
    public function dogearHome()
    {
        $this->doHomeEquipment();
        exit;
        $more = common::request('more', 'P');

        if($more == 1)
        {
            // 装备首页列表数据

            $result = array();

            // 数据类型及排序
            $types = array('gearNews', 'all', 'gearSet', 'gearEval', 'gearHot', 'gearNew');
            $orders = array('new', 'hot', 'best');

            $type = common::request('type', 'P', 'all');
            $order = common::request('order','P', 'new');
            $page = common::request('page', 'P', 1);
            !in_array($type, $types) && $type = $types[0];
            !in_array($order, $orders) && $order = $orders[0];
            (!is_numeric($page) || $page < 1 || $page > 100) && $page = 1;

            $result = $this->load('gear')->getGearListByType($type, $order, $page, 10);

            echo json_encode($result);
        }
        else
        {
            // 装备首页页面

            // 装备推荐轮播图
            $homeRecGear = $this->load('gear')->homeRecGear();

            $this->view->assign('homeRecGear',$homeRecGear);
            $this->view->display('show/index');
        }
    }
    /**
     * 装备首页(2.5.5+)
     */
    public function dogearHome1()
    {
        //编辑精选（装备合集）
        $this->view->assign('topSetList',$this->load('gear')->getTopSetList());
        $this->view->display('show/index');
    }
    /*
     * 阿里体育报名入口
     */
    public function doaliApply()
    {
        $this->in_user();
        $uid = $this->uid;
        $ca_money = 0;
        $eids = [];
        $aliuid = '';
        if($uid){
            $ca_money = $this->redis->hget(REDIS_PREFIX.'PartnerUserInfo_'.$uid,'ca_money');
            !$ca_money && $ca_money = 0;
            $res = $this->load('alibaba')->getAddInfo($uid);
            foreach($res as $row){
                $aliuid = $row['partner_uid'];
                $eids[] = $row['partner_eid'];
            }
        }

        $this->view->assign('uid',$uid);
        $this->view->assign('aliuid',$aliuid);
        $this->view->assign('appkey',$this->config['alibaba_sports']['AppKey']);
        $this->view->assign('ca_money',$ca_money);
        $this->view->assign('eids',$eids);
        $this->view->assign('staticHost', 'http://'.$this->config['host']);
        $this->view->assign('now',time());
        $this->view->display('show/ali-apply');
    }

    /*
     * 阿里体育首页
     */
    public function doaliEntrance()
    {
        $this->in_user();
        $uid = $this->uid;
        $this->view->assign('uid',$uid);
        $this->view->assign('staticHost', 'http://'.$this->config['host']);
        
        $this->view->display('show/ali-entrance');

    }

    /*
     * 阿里体育授权登录
     */
    public function doaliLogin()
    {
        $aliuid = common::request('aliuid','G');
        if(empty($aliuid)){
            common::go('http://wora.alisports.com/binding_error.html');
        }

        $this->in_user();
        $uid = $this->uid;
        $this->view->assign('aliuid',$aliuid);
        $this->view->assign('uid',$uid);
        $this->view->display('show/ali-login');
    }

    /*
     * 阿里登录
     */
    public function dopostAliLogin(){
        $aliuid = common::request('aliuid','P');
        $phone = common::request('phone','P');
        $pwd = common::request('pwd','P');

        if(empty($aliuid) || empty($phone) || empty($pwd) || !common::checkphone($phone)){
            common::go('http://wora.alisports.com/entroll/binding_error.html');
        }

        //用户是否存在
        $userInfo = $this->load('user')->getInfoByPhone($phone);
        if(empty($userInfo) || $this->redis->get(REDIS_PREFIX.'password_limit'.$userInfo['uid']) || $userInfo['pwd'] != md5($pwd)){
            common::go('http://wora.alisports.com/entroll/binding_error.html');
        }
        //是否重复
        $partnerUserInfo = $this->load('alibaba')->getUserInfo($userInfo['uid']);
        if($partnerUserInfo && $partnerUserInfo['partner_uid'] != $aliuid){
            common::go('http://wora.alisports.com/entroll/binding_error.html');
        }

        $appkey = $this->config['alibaba_sports']['AppKey'];
        $aliuid = $aliuid;
        $userid = $userInfo['uid'];
        common::go("http://wora.alisports.com/entroll/binding_finish.html?appkey={$appkey}&userid={$userid}&aliuid={$aliuid}");
    }


    public function doindexjs(){
        $p=common::request('p');;
        $type=common::request('type','R','');
        $order=common::request('order');
        if(empty($p)||empty($order)){
            exit('非法访问');
        }

        //一次返回多少数据
        $return=array('code'=>0,'msg'=>'成功','data'=>array());
        $limit=8;
        $redisKeyBase=REDIS_PREFIX.'gear_'.$order;

        //type对象redis的key
        if($type){
            $rediskey=$redisKeyBase.'_'.substr($type,0,1);
        }else{
             $rediskey=$redisKeyBase;
        }
        //获取从大到小的limit个键
        $ids=$this->redis->zrevrange($rediskey,($p-1)*$limit,$p*$limit-1);
        if(!$ids){
            $return['code']=1;
            $return['msg']='没有数据';
            exit(json_encode($return));
        }
       // common::pr($ids);
        $list=array();
        if($type){
            $gns=substr($type,0,1);
            $fun='showgearGet'.$gns;
            foreach($ids as $v){
                $tmp=$this->load('gear')->$fun($v);
                if($tmp){
                    $tmp['gns']=$gns;
                    $list[]=$tmp;
                }
            }

        }else{
            foreach($ids as $v){
                list($gns,$tmpid)=explode(':', $v);
                $fun='showgearGet'.$gns;
                $tmp=$this->load('gear')->$fun($tmpid);
                 if($tmp){
                    $tmp['gns']=$gns;
                    $list[]=$tmp;
                 }
            }
        }
        $return['data']['list']=$list;
        $return['data']['p']=$p;
        if($p==1){
            $return['data']['time']=date('Y-m-d H:i:s',time());
        }

        echo json_encode($return);
    }

    /**
    *2.5
    *不分页
    *装备更多评测
    */
    public function domoreNews(){
        $gearId=common::request('gearId','G');

        if(empty($gearId))exit ('错');
        $sql="SELECT news_id,title,thumb_img,sourceImg FROM r_news WHERE is_show=1 AND news_id In(SELECT nid FROM r_gear_ng WHERE gid={$gearId}) ORDER BY add_time";

        $list=$this->db->getAll($sql);
        foreach ($list as &$v ){
            $tmp=json_decode($v['thumb_img'],true);
            if(count($tmp)>3)$tmp=array($tmp[0],$tmp[1],$tmp[2]);
            $v['img']=$tmp;
            $v['imgs'] = json_decode($v['sourceImg'], TRUE);
        }
        $this->view->assign('list',$list);
        $this->view->display('show/moreNews');
    }

     /**
    *2.5
    *装备更多评评论
    */
    public function domoreComments(){
        $gearId=common::request('gearId','G');
        if(empty($gearId))exit;
        
        $this->view->assign('gearId',$gearId);
        $this->view->display('show/moreCommentsSub');
    }

     /**
    *2.5
    *装备更多评评论
    */
    public function domoreCommentsSub(){
        $gearId=common::request('gearId','G');
        if(empty($gearId))exit;
        
        $this->view->assign('gearId',$gearId);
        $this->view->display('show/moreCommentsSub');
    }

    

    /**
    *++2.5
    * 装备性能，感受
    */
    public function dogearPp($diaoyong=false,$gearId=0)
    {
        $gearId =$gearId?: common::request("gearId", 'G', 0);
        $gearId = intval($gearId);
        $gearInfo = $this->load('gear')->getGearInfo($gearId);
        if($gearId < 1 || empty($gearInfo) || $gearInfo['isShow'] != 1)
        {
            header('Location: http://run.hupu.com/mobile?r=404');
            exit();
        }

        $result = array('gearId' => $gearInfo['gearId'],
                        'name'  => $gearInfo['name'],
                        'shortDesc'  => $gearInfo['shortDesc'],
                        'images'  => $gearInfo['images'],
                        'price'  => $gearInfo['price'],
                        'currency'  => $gearInfo['currency'],
                        'likes'  => intval($gearInfo['likes']),
                        'comments'  => $gearInfo['comments'],
                        'shopUrl'  => $gearInfo['shopUrl'],
                        'evaluate'  => $gearInfo['evaluate'],
                        'image'  => empty($gearInfo['images']) ? '' : $gearInfo['images'][0],
            );
        $shoeAttr = common::$shoeAttr;
        $footType = array();
        $footCircle = array();
        if(!empty($gearInfo['footType'])){
            foreach ($gearInfo['footType'] as $v) {
                $footType[] = $shoeAttr['footType'][$v];
            }
        }

        $footType = implode(',',$footType);
        if(!empty($gearInfo['footCircle'])){
            foreach ($gearInfo['footCircle'] as $v) {
                $footCircle[] = $shoeAttr['footCircle'][$v];
            }
        }
        $footCircle = implode(',',$footCircle);
        $attrs = array('gender' => $gearInfo['gender'] == 1 ? '男' :'女',
                        'shoeCat' => $gearInfo['shoeCat']!=0 ? $shoeAttr['shoeCat'][$gearInfo['shoeCat']] : '',
                        'footType' => str_replace(',','，',$footType),
                        'footCircle' => str_replace(',','，',$footCircle),
                        'feature' => $gearInfo['feature']!=0 ? $shoeAttr['feature'][$gearInfo['feature']] : '',
            );

        if($gearInfo['gender'] == 1){
            $attrs['gender'] = '男';
        }else if($gearInfo['gender'] == 2){
            $attrs['gender'] = '女';
        }else {
            $attrs['gender'] = '男女通用';
        }

        if($diaoyong){
            $redata['gear']=$gearInfo;
            $redata['attrs']=$attrs;
            return $redata;
        }

        $this->view->assign('gear', $gearInfo);
        $this->view->assign('attrs', $attrs);
        $this->view->assign('staticHost', $this->config['img-host']);

        $this->view->display('show/gearDetial');
    }
    /**
    *2.5新增，原来是原生
    *装备对比
    *
    */
    public function dogearCompare()
    {
        $gids = common::request('gids');
        $gearCids = common::request('joggers_gear_cids', 'C');

        if($gids)
        {
            $gids = explode(',', $gids);
            $gidsTmp = $gids;
            $gids = array();

            foreach($gidsTmp as $gid)
            {
                $gid = trim($gid);
                is_numeric($gid) && $gids[] = $gid;
            }
        }

        if($gearCids)
        {
            $gearCids = explode(',', $gearCids);
            $gearCidsTmp = $gearCids;
            $gearCids = array();

            foreach($gearCidsTmp as $key => $gid)
            {
                $gid = trim($gid);
                is_numeric($gid) && $gearCids[] = $gid;
            }
        }

        if($gids && count($gids) == 2)
        {
            // 装备对比详情

            $result = array();

            foreach ($gids as $key => $gid)
            {
                $result[] = static::dogearPp(TRUE , $gid);
            }

            $this->view->assign('compare', $result);
            $this->view->display('show/gearCompare');
        }
        else
        {
            // 装备对比列表

            $gearInfos = array();

            if($gearCids)
            {
                $gearInfos = $this->load('gear')->getGearInfo($gearCids);
            }

            $this->view->assign('gearInfos', $gearInfos);
            $this->view->display('show/moreCompare');
        }
    }

    /*
     * 装备详情
     */
    public function dogear()
    {
        $gearId = common::request("gearId", 'G', 0);
        $gearId = intval($gearId);
        $gearInfo = $this->load('gear')->getGearInfo($gearId);
        if($gearId < 1 || empty($gearInfo) || $gearInfo['isShow'] != 1)
        {
            header('Location: http://run.hupu.com/mobile?r=404');
            exit();
        }
        $fromApp = $this->in_verifySign(false);// 判断是否来自己APP的请求
        $fromApp = $fromApp ? 1 : 0;
        $isLike = 0;
        $isCompare = 0;
        $likeUrl = '';
        $compareUrl = 'javascript:;';
        $commentUrl = 'javascript:;';
        $comListUrl = 'javascript:;';
        if($fromApp)
        {
            $token = common::request('token', 'G');
            $tokenArr = explode('-', $token);
            $uid = intval($tokenArr[0]);
            $this->redis->ZSCORE(REDIS_PREFIX.'GearLikeList_'.$gearId, $uid)  != false && $isLike = 1;
            $token && $likeUrl = 'http://'.$this->config['host'].'/ajax/likegear?gearId='.$gearId.'&token='.$token;
            $compareUrl = 'joggers://gearInCompare/'.$gearId;
            $commentUrl = 'joggers://gearComment/'.$gearId;
            $comListUrl = 'joggers://gearCommentList/'.$gearId;
            $isCompare = common::request("isCompare", 'G', 0);
        }
        $result = array('gearId' => $gearInfo['gearId'],
                        'name'  => $gearInfo['name'],
                        'shortDesc'  => $gearInfo['shortDesc'],
                        'images'  => $gearInfo['images'],
                        'price'  => $gearInfo['price'],
                        'currency'  => $gearInfo['currency'],
                        'likes'  => intval($gearInfo['likes']),
                        'comments'  => $gearInfo['comments'],
                        'shopUrl'  => $gearInfo['shopUrl'],
                        'shopName' => common::detectShop($gearInfo['shopUrl']),
                        'evaluate'  => $gearInfo['evaluate'],
                        'image'  => empty($gearInfo['images']) ? '' : $gearInfo['images'][0],
            );
        $shoeAttr = common::$shoeAttr;
        $footType = array();
        $footCircle = array();
        foreach ($gearInfo['footType'] as $v) {
            $footType[] = $shoeAttr['footType'][$v];
        }
        $footType = implode(',',$footType);
        foreach ($gearInfo['footCircle'] as $v) {
            $footCircle[] = $shoeAttr['footCircle'][$v];
        }
        $footCircle = implode(',',$footCircle);
        $attrs = array('gender' => $gearInfo['gender'] == 1 ? '男' :'女',
                                'shoeCat' => $shoeAttr['shoeCat'][$gearInfo['shoeCat']],
                                'footType' => $footType,
                                'footCircle' => $footCircle,
                                'feature' => $shoeAttr['feature'][$gearInfo['feature']],
                                'weight' => $gearInfo['weight'] .'克',
                                'publishTime' => date("Y-m-d", $gearInfo['publishTime'])
            );
        $commentList = $this->load('gear')->getCommentList($gearId, 0,'next', 3);
        $similarGear = $this->load('gear')->getSimilarGear($gearInfo['shoeCat'], $gearInfo['feature'], 10);
        if($similarGear)
        {
            $host = 'http://'.$this->config['host'];
            foreach ($similarGear as & $v) {
                $v['name'] = $this->load('bbs')->cutString($v['name'], 20);
                $v['url'] = $fromApp ? 'joggers://gearShoe/'.$v['gearId'] : $host.'/shoe/'.$v['gearId'].'.html';
            }
        }
        count($commentList) < 3 && $comListUrl = 'javascript:;';

        if($commentList)
        {
            foreach($commentList as $k => $comment)
            {
                $image = json_decode($comment['image']);
                $thumbImg = json_decode($comment['thumbImg']);
                $commentList[$k]['image'] = !empty($image[0]) ? $image[0] : '';
                $commentList[$k]['thumbImg'] = !empty($thumbImg[0]) ? $thumbImg[0] : '';
            }
        }

        $this->view->assign('gear', $result);
        $this->view->assign('attrs', $attrs);
        $this->view->assign('commentList', $commentList);
        $this->view->assign('similarGear', $similarGear);
        $this->view->assign('staticHost', $this->config['img-host']);
        $this->view->assign('isCompare', $isCompare);
        $this->view->assign('fromApp', $fromApp);
        $this->view->assign('isLike', $isLike);
        $this->view->assign('likeUrl', $likeUrl);
        $this->view->assign('compareUrl', $compareUrl);
        $this->view->assign('commentUrl', $commentUrl);
        $this->view->assign('comListUrl', $comListUrl);
        $this->view->display('gearShare');
    }

    /**
     * 2.5.5
     * 装备详情
     */
    public function dogearInfo()
    {
        $this->doequipment();
        exit;

        $gearId =(int)common::request("gearId", 'G', 0);
        $token = common::request('token', 'P');
        $tokenArr = explode('-', $token);
        $tuid = intval($tokenArr[0])? :common::request('uid','R',0);

        $gearInfo = $this->load('gear')->getGearInfo($gearId);
        if($gearId < 1 || empty($gearInfo) || $gearInfo['isShow'] != 1)
        {
            header('Location: http://run.hupu.com/mobile?r=404');
            exit();
        }
        $fromApp = $this->in_verifySign(false);// 判断是否来自己APP的请求
        $fromApp = $fromApp ? 1 : 0;
        $isLike = 0;
        $isCompare = 0;
        $likeUrl = '';
        // $compareUrl = 'javascript:;';
        // $commentUrl = 'javascript:;';
        // $comListUrl = 'javascript:;';
        if($fromApp)
        {
            $token = common::request('token', 'G');
            $tokenArr = explode('-', $token);
            $uid = intval($tokenArr[0]);
            $this->redis->ZSCORE(REDIS_PREFIX.'GearLikeList_'.$gearId, $uid)  != false && $isLike = 1;
            $token && $likeUrl = 'http://'.$this->config['host'].'/ajax/likegear?gearId='.$gearId.'&token='.$token;
            // $compareUrl = 'joggers://gearInCompare/'.$gearId;
            // $commentUrl = 'joggers://gearComment/'.$gearId;
            // $comListUrl = 'joggers://gearCommentList/'.$gearId;
            $isCompare = common::request("isCompare", 'G', 0);
        }

        $gearInfo['shopName'] = common::detectShop($gearInfo['shopUrl']);
        $result = array('gearId' => $gearInfo['gearId'],
                        'name'  => $gearInfo['name'],
                        'shortDesc'  => $gearInfo['shortDesc'],
                        'images'  => $gearInfo['images'],
                        'price'  => $gearInfo['price'],
                        'currency'  => $gearInfo['currency'],
                        'likes'  => intval($gearInfo['likes']),
                        'possess'=> intval($gearInfo['possess']),
                        'comments'  => $gearInfo['comments'],
                        'shopUrl'  => $gearInfo['shopUrl'],
                        'evaluate'  => $gearInfo['evaluate'],
                        'image'  => empty($gearInfo['images']) ? '' : $gearInfo['images'][0],
                        'shopName' => $gearInfo['shopName'],
            );
        $shoeAttr = common::$shoeAttr;
        $footType = array();
        $footCircle = array();

        if(!empty($gearInfo['footType']))
        {
            foreach ($gearInfo['footType'] as $v) {
                $footType[] = $shoeAttr['footType'][$v];
            }
        }

        $footType = implode(',',$footType);

        if(!empty($gearInfo['footCircle']))
        {
            foreach ($gearInfo['footCircle'] as $v) {
                $footCircle[] = $shoeAttr['footCircle'][$v];
            }
        }

        $footCircle = implode(',',$footCircle);
        $attrs = array('gender' => $gearInfo['gender'] == 1 ? '男' :'女',
                                'shoeCat' => $shoeAttr['shoeCat'][$gearInfo['shoeCat']],
                                'footType' => $footType,
                                'footCircle' => $footCircle,
                                'feature' => $shoeAttr['feature'][$gearInfo['feature']],
                                'weight' => $gearInfo['weight'] .'克',
                                'publishTime' => date("Y-m-d", $gearInfo['publishTime'])
            );
        //获取评测，一条
        $sql="SELECT news_id,title,thumb_img,sourceImg FROM r_news WHERE is_show=1 AND news_id In(SELECT nid FROM r_gear_ng WHERE gid={$gearId}) ORDER BY add_time limit 1";
        $news=$this->db->getRow($sql);
        if($news){
            $tmp=json_decode($news['thumb_img'],true);
            if(count($tmp)>3)$tmp=array($tmp[0],$tmp[1],$tmp[2]);
            $news['img']=$tmp;
            $news['imgs'] = json_decode($news['sourceImg'], TRUE);
        }
        //获取评论，一条
        $sql="SELECT commentId,r_gear_comment.uid,nickname,header,content,image,thumbImg,score,r_gear_comment.addTime,usefull,nouse FROM r_gear_comment LEFT JOIN r_user ON r_gear_comment.uid=r_user.uid where isShow=1 AND gearId={$gearId} order by commentId desc limit 1";
        $comment=$this->db->getRow($sql);
        if($comment){
            $comment['dateformat']=common::timediff(time()-$comment['addTime']);
            $comment['image'] && $comment['image'] = json_decode($comment['image'], TRUE);
            $comment['thumbImg'] && $comment['thumbImg'] = json_decode($comment['thumbImg'], TRUE);
        }
        $similarGear = $this->load('gear')->getSimilarGear($gearInfo['shoeCat'], $gearInfo['feature'], 10);
        if($similarGear)
        {
            $host = 'http://'.$this->config['host'];
            foreach ($similarGear as & $v) {
                $v['name'] = $this->load('bbs')->cutString($v['name'], 20);
                $v['url'] = $fromApp ? 'joggers://gearShoe/'.$v['gearId'] : $host.'/shoe/'.$v['gearId'].'.html';
            }
        }

        //配色
        $gearBlendent=$this->load('gear')->getBlendent($gearId);
       // common::pr($gearBlendent);

        $isInAppWebview = common::isInAppWebview();

        $this->view->assign('isInAppWebview',$isInAppWebview);
        $this->view->assign('uid',$tuid);
        $this->view->assign('gear', $gearInfo);
        $this->view->assign('gearId', $gearId);
        $this->view->assign('attrs', $attrs);
        $this->view->assign('news',$news);
        $this->view->assign('comment', $comment);
        $this->view->assign('similarGear', $similarGear);
        $this->view->assign('staticHost', $this->config['img-host']);
        $this->view->assign('blendent',$gearBlendent);
        // $this->view->assign('isCompare', $isCompare);
        // $this->view->assign('fromApp', $fromApp);
        // $this->view->assign('compareUrl', $compareUrl);
        // $this->view->assign('commentUrl', $commentUrl);
        // $this->view->assign('comListUrl', $comListUrl);
        $this->view->display('show/gearInfo');
    }

    /**
     * 喜欢装备
    */
    public function dolikeGear()
    {
        $code = 2;
        $msg = '失败';
        $rel = array('code' => & $code, 'msg' => & $msg);
        $gearId = common::request('gearId', 'G');
        $gearId = intval($gearId);
        $token = common::request('token', 'G');
        $islike = common::request('like', 'G');  // 是否已喜欢

        $tokenArr = explode('-', $token);
        $uid = intval($tokenArr[0]);
        $time = isset($tokenArr[1]) ? intval($tokenArr[1]):'';
        $md5Str = isset($tokenArr[2]) ? trim($tokenArr[2]):'';
        $tokenStr = $this->config['tokenStr'];
        if(md5($uid.$time.$tokenStr) != $md5Str)
        {
            $code = 1;
            $msg = '亲， 请先登录';
            exit(json_encode($rel));
        }

        $gearId = intval($gearId);
        if($islike)
        {
            if($this->load('gear')->unlikeGear($gearId, $uid))
            {
                $code = -1;
                $msg = '';
            }
        }
        else
        {
            if($this->load('gear')->likeGear($gearId, $uid))
            {
                $code = 1;
                $msg = '';
            }
        }
        exit(json_encode($rel));
    }

    // 装备合辑喜欢
    public function dosetLike()
    {
        $result = -1;

        $gid = common::request('sid', 'P');
        $gid = intval($gid);

        $this->in_user();
        if($this->uid && $gid)
        {
            $redisKey = REDIS_PREFIX . 'GearSetLike_' . $gid;

            if(!$this->redis->sismember($redisKey, $this->uid))
            {
                if($this->redis->sadd($redisKey, $this->uid))
                {
                    $this->db->update("update r_gear set likes=likes+1 where gearId='{$gid}'");
                }

                $result = 1;
            }
            else
            {
                if($this->redis->srem($redisKey, $this->uid))
                {
                    $this->db->update("update r_gear set likes=likes-1 where gearId='{$gid}' and likes>0");
                }

                $result = 2;
            }
        }

        echo $result;
    }

    /**
     *++v2.5.0
    *装备，想要
    */
    public function dolikes()
    {
        $gearId = common::request('gid', 'P');
        $action = common::request('action', 'P');
        $gearId = intval($gearId);

        $this->in_user();

        if($this->uid)
        {
            if(empty($action)){
                if($this->redis->sadd($this->redisKeyBase.'likes_'.$gearId, $this->uid))
                {
                    $this->db->insertRow('r_gear_likes', array('gearId' => $gearId, 'uid' => $this->uid, 'addTime' => $this->time, 'isShow' => 1), 1);
                    $this->db->query("update r_gear set likes=likes+1 where gearId={$gearId}");

                    //如果有老数据，这里可能会返回的数字不一样 ,如果没有老数据最好用redis那行
                    echo $this->db->getOne("select likes from r_gear where gearId={$gearId}");
                }
                else
                {
                    echo -2;
                }
            } else if($action=='query'){
                if($this->redis->sismember($this->redisKeyBase.'likes_'.$gearId, $this->uid))
                    echo 1;
                else 
                    echo 2;
            } else if($action=='del'){
                if($this->redis->srem($this->redisKeyBase.'likes_'.$gearId, $this->uid))
                {
                    $this->db->update("delete from r_gear_likes where uid=".$this->uid." and gearId=".$gearId);
                    $this->db->query("update r_gear set likes=likes-1 where gearId={$gearId}");

                    //如果有老数据，这里可能会返回的数字不一样 ,如果没有老数据最好用redis那行
                }
                echo $this->db->getOne("select likes from r_gear where gearId={$gearId}");
            }
        }
        else
        {
            echo -1;
        }
    }

    /**
     *++v2.5.0
     *装备，拥有
     */
    public function dopossess()
    {
        $gearId=(int)common::request('gid', 'P');

        $this->in_user();

        if($this->uid)
        {
            if(!$this->db->getOne("select count(1) from r_gear_comment where uid='{$this->uid}' and gearId='{$gearId}' and score>0"))
            {
               echo 1;
            }
            else
            {
                echo -2;
            }
        }
        else
        {
            echo -1;
        }
    }
    /**
     * 评论有用
     */
    public function dousefull()
    {
        $result = -1;

        $cid = common::request('cid','P');
        $cid = intval($cid);

        $this->in_user();
        if($this->uid)
        {
            if($this->redis->sadd($this->redisKeyBase.'usefull_'.$cid,$this->uid))
            {
                $sql="update r_gear_comment set usefull=usefull+1 where commentId={$cid}";
                $this->db->query($sql);

                $result = $this->redis->scard($this->redisKeyBase.'usefull_'.$cid);
            }
            else
            {
                $result = -2;
            }
        }

        echo $result;
    }
    /**
     * 评论没用
     */
    public function donouse()
    {
        $result = -1;

        $cid = common::request('cid','P');
        $cid = intval($cid);

        $this->in_user();
        if($this->uid)
        {
            if($this->redis->sadd($this->redisKeyBase.'nouse_'.$cid, $this->uid))
            {
                $sql="update r_gear_comment set  nouse=nouse+1 where commentId={$cid}";
                $this->db->query($sql);

                $result = $this->redis->scard($this->redisKeyBase.'nouse_'.$cid);
            }
            else
            {
                $result = -2;
            }
        }

        echo $result;
    }

    /*
     * 关于我们
    */
    public function doAboutUs()
    {
        $this->view->display('aboutUs');
    }
    /*
     * 活动列表页面
    */
    public function doactivityList()
    {
        $activityList = $this->load('activity')->activityList();

        $bannerList = $this->load('banner')->getBanner('activityListBanner');
        $this->view->assign('list', $activityList);
        $this->view->assign('bannerList',$bannerList);
        $this->view->assign('staticHost', $this->config['img-host']);
        $this->view->display('activityListWeb');
    }

    public function dogoActivity()
    {
        $aid = intval(common::request('aid', 'R'));
        $isAbnormal = TRUE;

        if($aid)
        {
            $activity = $this->load('activity')->getActivityInfo($aid);

            if($activity)
            {
                $this->load('activity')->incrbyActivityUv($aid);
                $isAbnormal = FALSE;
                common::go($activity['link']);
            }
        }

        if($isAbnormal)
        {
            common::go('http://ijoggers.com');
        }
    }

    //我的活动
    public function domyActivity(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/activity_me');
    }

    //全部活动
    public function doactList(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/activity_all');
    }

    //群组活动
    public function dogroupAct(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/activity_list');
    }

    //活动详情
    public function dodetail(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/activity_ldetails');
    }

    //活动统计
    public function dostatistics(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/activity_statistics');
    }

    //认证介绍
    public function doauthIntro(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/attestation');
    }

    //认证页面
    public function dogroupAuth(){
        $oid = uniqid("AUTH");
        $this->view->assign('oid',$oid);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/team_approve');
    }

    //认证详情
    public function doauthDetail(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/team_approve_result');
    }

    //我的排行
    public function domyRank(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/ranking_me');
    }

    //排行榜
    public function dorankList(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/ranking_list');
    }
     //活动成员
    public function doacMmember(){
        $this->view->assign('aid',common::request('aid','R'));
        $this->view->assign('gid',common::request('gid','R'));
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/activity_member');
    }
     // 物流信息

    public function dologistics(){
        $shipping_num = common::request('num','G');
        $shipping_code = common::request('code','G');
        $this->view->assign('num',$shipping_num);
        $this->view->assign('code',$shipping_code);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/logistics');
    }

    /**
     * 订单详情
     */
    public function doorderDetail(){
        $order_id = common::request('order_id','G');
        $this->view->assign('order_id',$order_id);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/order_details');
    }

    /**
     * 活动详情
     */
    public function donewDetail(){
        $aid = common::request('aid','G');
        $gid = common::request('gid','G');
        $actInfo = $this->load('groupActivity')->getActByAid($aid);
        $shareToken = common::request('shareToken','G');
        if(empty($actInfo)){
            header('Location: http://run.hupu.com/mobile?r=404');
            exit();
        }
        if($shareToken){
            $shareToken = base64_decode($shareToken);
            $shareToken = explode('_',$shareToken);
            if(count($shareToken)==2){
                list($fromUid,$shareAid) = $shareToken;
                if($shareAid == $aid){
                    $this->load('client')->userEnergyChange($fromUid,'shareActivity',$aid);
                }
            }
        }

        $this->in_user();
        $uid = $this->uid;
        $this->view->assign('aid',$aid);
        $this->view->assign('gid',$gid);
        $this->view->assign('user_uid',$uid);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        if($actInfo['type'] > 2){
            $this->view->display('show/activity_ldetails_official');
        }else{
            $this->view->display('show/activity_ldetails_new');
        }
    }

    /**
     * 活动排行
     */
    public function dorank(){
        $aid = common::request('aid','G');
        $gid = common::request('gid','G');
        $type = common::request('type','G',1);
        $actInfo = $this->load('groupActivity')->getActByAid($aid);
        if(empty($actInfo) || empty($gid)){
            header('Location: http://run.hupu.com/mobile?r=404');
            exit();
        }
        $this->view->assign('type',$type);
        $this->view->assign('aid',$aid);
        $this->view->assign('gid',$gid);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        if($actInfo['type'] <= 2){
            $this->view->display('show/rank_clock');
        }elseif($actInfo['type'] > 2 && $type == 1){
            $this->view->display('show/rank_official');
        }else{
            $this->view->display('show/rank_official_one');
        }
    }
        public function doauth(){
        $gid = common::request('gid',"P");
        $realname = common::request('name',"P");
        $phone = common::request('phone',"P");
        $card = common::request('card',"P");
        $info = common::request('info','P');
        $oid = common::request('oid','P');
        $uid = $this->uid;
        $add_time = time();
        $status = 0;
        $ainfo = $this->load('group')->getAuthGroup($gid);
        $img = $this->redis->get(REDIS_PREFIX."AuthImg_".$oid);
        if(!empty($ainfo)){
            $data['id'] = $ainfo['id'];
            $img = !empty($img) ? $img : $info['img'];
        }
        $data = compact('uid','gid','realname','phone','card','info','img','add_time','status');
        $id = $this->db->updateRowTable('r_group_auth',$data);
        $this->redis->del(REDIS_PREFIX."AuthImg_".$oid);
        if($id > 0){
            header("location:http://".$this->config['host']."/show/authDetail?gid=".$gid);
        }

    }

    public function dogoodsDetail(){
        $goodsId = common::request("goods_id",'G');
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('gid',$goodsId);
        $this->view->display('show/commodity_ldetails');
    }

    /*
     * 赛事详情
     */
    public function domatchInfo(){
        $this->in_user();
        if(common::isInWeixin()){
            $this->load('user')->checkWxPubOpenId();
        }
        $match_id = common::request('match_id','G');
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('match_id',$match_id);
        $this->view->assign('uid',$this->uid);
        $this->view->display('show/competition');
    }

    /*
     * 赛事说明
     */
    public function domatchApply(){
        $this->in_user();
        $match_id = common::request('match_id','G');
        //$goodsDetailUrl = common::isInAppWebview() ? 'joggers://order/goodsDetail?atype=match&aid='.$match_id : "http://".$this->config['host'].'/show/matchOrderConfirm?atype=match&match_id='.$match_id;
        $goodsDetailUrl = "http://".$this->config['host'].'/show/matchOrderConfirm?atype=match&match_id='.$match_id;
        
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('match_id',$match_id);
        $this->view->assign('uid',$this->uid);
        $this->view->assign('goodsDetailUrl',$goodsDetailUrl);
        $this->view->display('show/competition-apply');
    }
    // 赛事个人报名 新
    public function domatchIntroduce(){
        $match_id = common::request('match_id','G');
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('match_id',$match_id);
        $this->view->display('show/competition-explain');
    }

    /*
     * 赛事排名
     */
    public function domatchRank(){
        $match_id = common::request('match_id','G');
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('match_id',$match_id);
        $this->view->display('show/competition-rank');
    }

    /*
     * 赛事证书
     */
    public function domatchCertificate(){
        $match_id = common::request('match_id','G');
        if($match_id==33){
            common::go('http://joggers-test.qiniudn.com/PostImg_0cb4d34ca842eb89f88cc9164f63250d.jpg');
            exit;
        }
        $uid = common::request('uid','G');
        $this->view->assign('doller','$');
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('match_id',$match_id);
        $this->view->assign('uid',$uid);
        $this->view->display('show/competition-zs');
    }

    /*
     * 赛事订单详情
     */
    public function domatchOrderInfo(){
        $order_id = common::request('order_id','G');
        $this->view->assign('order_id',$order_id);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/order_details-sh');
    }

    /*
     * 赛事订单预览（确认，购物车）
     */
    public function domatchOrderConfirm(){
        $goods_id = common::request('goods_id','G');
        $match_id = common::request('match_id','G');

        $this->view->assign('match_id',$match_id);
        $this->view->assign('goods_id',$goods_id);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/order_confirm');
    }

    /*
     * 赛事订单预览（确认，购物车）
     */
    public function dogoodsDetails(){
        $match_id = common::request('match_id','R');
        $goods_ids = common::request('goods_ids','R');
        $this->view->assign('match_id',$match_id);
        $this->view->assign('goods_ids',$goods_ids);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/goods_details');
    }

    /*
     * 赛事订单列表
     */
    public function domatchOrderList(){
        $match_id = common::request('match_id','G');
        $this->view->assign('match_id',$match_id);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/order-my');
    }

    /*
     * 扫码登陆
     */
    public function doarticle(){
        if(common::is_mobile()){
            common::go('http://run.hupu.com/mobile');
        }

        $logout = common::request('logout','G');
        if($logout){
            $expire = time()-3600;
            setcookie('auth_key','',$expire,'/');
            setcookie('token','',$expire,'/');
            common::go('http://'.$this->config['pc-host'].'/show/article');
        }

        $auth_key = isset($_COOKIE['auth_key']) ? $_COOKIE['auth_key'] : null;
        $token = isset($_COOKIE['token']) ? urldecode($_COOKIE['token']) : null;
        if($auth_key && $token){
            $_session = $this->redis->hgetall(REDIS_PREFIX.'postDraft_'.$auth_key);
            if(isset($_session[$token]) && $_session['news_draft_id']){
                common::go('http://'.$this->config['pc-host'].'/show/articleEditor?news_draft_id='.$_session['news_draft_id']);
                exit;
            }
        }

        $auth_key = common::getHashStr(12);
        $auth_value1 = common::getHashStr(12);
        $auth_value2 = common::getHashStr(12);

        $app_key = $this->config['app_key'];
        $str = json_encode(compact('auth_key','auth_value1'));
        $code = mcrypt_encrypt(MCRYPT_RIJNDAEL_128,$app_key,$str,MCRYPT_MODE_ECB);

        $redisKey = REDIS_PREFIX.'postDraft_'.$auth_key;
        $this->redis->hset($redisKey,'auth_value1',$auth_value1);
        $this->redis->hset($redisKey,'auth_value2',$auth_value2);
        $this->redis->expire($redisKey,120);

        $this->view->assign('auth_key',$auth_key);
        $this->view->assign('auth_value2',$auth_value2);
        $this->view->assign('code',urlencode(base64_encode($code)));
        $this->view->assign('socket_address','http://'.$this->config['socket_host']);
        $this->view->assign('socket_port',$this->config['socket_port']);
        $this->view->assign('staticHost', "http://".$this->config['pc-host']);
        $this->view->display('show/article');
    }

    /*
     * 输出登录二维码
     */
    public function doqrcode(){
        $code = common::request('code','G');
        require FILE . 'lib/phpqrcode.php';
        $code = '{"a":"postDraft","code":"'.$code.'"}';
        //QRcode::png($code);

        //加logo
        $QR1 = common::getHashStr(12).'.png';
        QRcode::png($code, $QR1, 'L', 6, 2);
        $logo = FILE . '../web/logo54.png';

        if($logo != false){
            $QR = imagecreatefromstring(file_get_contents($QR1));
            $logo = imagecreatefromstring(file_get_contents($logo));
            $QR_width = imagesx($QR);//二维码图片宽度
            $QR_height = imagesy($QR);//二维码图片高度
            $logo_width = imagesx($logo);//logo图片宽度
            $logo_height = imagesy($logo);//logo图片高度
            $logo_qr_width = $QR_width / 5;
            $scale = $logo_width/$logo_qr_width;
            $logo_qr_height = $logo_height/$scale;
            $from_width = ($QR_width - $logo_qr_width) / 2;
            //重新组合图片并调整大小
            imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
            $logo_qr_height, $logo_width, $logo_height);
        }

        imagepng($QR);
        unlink($QR1);
    }

   /*
    * 上传单张图片
    */
    public function douploadFile(){
        $res = $this->load('bbs')->getPostImage('images_',1,0);
        extract($res);//'sourceImg', 'thumbImg', 'imgHtml', 'validImg'

        if(isset($sourceImg[0])){
            $result = [
                'success'=>true,
                "file_path"=> $sourceImg[0]
            ];
        }else{
            $result = [
                'success'=>false
            ];
        }
        echo json_encode($result);
    }

    /*
     * PC端编辑器
     */
    public function doarticleEditor(){
        $auth_key = common::request('auth_key','G');
        $token = common::request('token','G');
        if($auth_key && $token){
            $expire = time()+48*24*3600;
            setcookie('auth_key',$auth_key,$expire,'/');
            setcookie('token',$token,$expire,'/');
        }

        $auth_key = isset($_COOKIE['auth_key']) ? $_COOKIE['auth_key'] : null;
        $token = isset($_COOKIE['token']) ? $_COOKIE['token'] : null;
        $uid = null;
        if($auth_key && $token){
            $uid = $this->redis->hget(REDIS_PREFIX.'postDraft_'.$auth_key,$token);
        }

        if(!$uid){
            common::go('http://'.$this->config['pc-host'].'/show/article');
            exit;
        }
        $news_draft_id = common::request('news_draft_id','G');
        if(empty($news_draft_id)){
            common::go('http://'.$this->config['pc-host'].'/show/article');
            exit;
        }

        $postInfo = $this->db->getRowTable('r_news_draft',[],'news_draft_id='.$news_draft_id);
        if(!$postInfo || $postInfo['uid'] != $uid){
            common::go('http://'.$this->config['pc-host'].'/show/article');
            exit;
        }
        $author = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$uid, 'nickname');

        $this->view->assign('postInfo',$postInfo);
        $this->view->assign('uid',$this->uid);
        $this->view->assign('author',$author);
        $this->view->assign('staticHost', "http://".$this->config['pc-host']);
        $this->view->display('show/article-editor');
    }

    /*
     * 保存草稿
     */
    public function doarticleAction(){
        $auth_key = isset($_COOKIE['auth_key']) ? $_COOKIE['auth_key'] : null;
        $token = isset($_COOKIE['token']) ? $_COOKIE['token'] : null;

        $uid = null;
        if($auth_key && $token){
            $uid = $this->redis->hget(REDIS_PREFIX.'postDraft_'.$auth_key,$token);
        }
        if(!$uid){
            common::go('http://'.$this->config['pc-host'].'/show/article');
            exit;
        }

        $news_draft_id = common::request('news_draft_id','P');
        $title = common::request('title','P');
        $content = common::request('content','P');

        if(empty($news_draft_id)){
            common::go('http://'.$this->config['pc-host'].'/show/article');
            exit;
        }
        $this->in_user();

        $postInfo = $this->db->getRowTable('r_news_draft',[],'news_draft_id='.$news_draft_id);
        if(!$postInfo || $postInfo['uid'] != $uid){
            common::go('http://'.$this->config['pc-host'].'/show/article');
            exit;
        }

        $error = '';
        // 检查 title
        if(empty($title)){
            $error = '标题不能为空';
        }
        if($this->load('badwords')->check($title) || $this->load('badwords')->check($content))
        {
            $error = '标题或内容里有不合适词汇';
        }

        // 检查 content
        $clean_content = strip_tags($content);
        if(empty($clean_content))
        {
            $error = '内容不能为空';
        }

        if(!$error){
            $short_desc = $this->load('bbs')->cutString($clean_content, 100);

            extract($this->load('admin')->digPostImg($content));//$content  $sourceImg  $thumb_img
            $validImg = [];
            $this->load('bbs')->addPost($postInfo['boardId'],$postInfo['uid'],$title,$content,$short_desc,$sourceImg,$thumb_img,$postInfo['tag'],$validImg,$postInfo['type'],$postInfo['gid'],$postInfo['synchronize'],$postInfo['lat'],$postInfo['lng'],1);

            $expire = time()-3600;
            setcookie('auth_key','',$expire,'/');
            setcookie('token','',$expire,'/');
            $this->redis->del(REDIS_PREFIX.'postDraft_'.$auth_key);
        }

        $this->view->assign('error',$error);

        $this->view->assign('staticHost', "http://".$this->config['pc-host']);
        $this->view->display('show/article-over');
    }

    /*
     * 2.8.2卡片详情
     */
    public function docardList(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/card-list');
    }


    public function doorderPay(){
        if(common::isInWeixin()){
            $this->load('user')->checkWxPubOpenId();
        }
        $order_id = common::request('order_id','G');
        $this->view->assign('order_id',$order_id);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/order_pay');
    }

    public function dopaySuccess(){
        $order_id = common::request('order_id','G');
        $match_id = common::request('match_id','G','0');

        $this->view->assign('order_id',$order_id);
        $this->view->assign('match_id',$match_id);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/pay-success');
    }

    /*
    *  goods.html
    */
    public function dogoods(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/goods');
    }

    /*
    *  order.html
    */
    public function doorder(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/order');
    }

    /*
    *  运动会 分享页
    */
    public function doshare(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/share');
    }

    /*
    *  九月运动会--首页
    */
    public function dosportHome(){
        $this->in_user();
        $uid = $this->uid;
        $isJoin = 0;
        if(!$uid){
            //网页端登录--irun.hupu.com/connect/login
            common::go('joggers://login', true);
        }elseif(!common::isInAppWebview()){
            $rUrl = "http://".$this->config['host'].'/show/share';   //填写分享页
        }else{
            //查看用户是否已参与活动
            $isJoin = $this->db->getOne("select count(1) from r_sports_september where acttype = 1 and uid = {$uid}");
            $rUrl = "http://".$this->config['host'].'/show/sport';
            //$rUrl = 'index.php?c=show&a=sport';
            if($isJoin == 0){
                //$rUrl = 'index.php?c=show&a=sport';
                $rUrl = "http://".$this->config['host'].'/show/joinactivity';
            }
        }

        $this->view->assign('rUrl', $rUrl);
        $this->view->assign('firstEnter', $isJoin);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/sportHome');
    }

    /*
    *  九月运动会--参与活动接口
    */
    public function dojoinactivity(){
        $this->in_user();
        $uid = $this->uid;

        if(!$uid)
        {
            common::tips('请先登录');
            exit;
        }

        $add_time = time();
        $acttype = 1;  //活动类型：跑步运动会
        $params = compact('uid', 'add_time', 'acttype');

        $this->db->insertRowTable('r_sports_september', $params);
        common::go("http://".$this->config['host'].'/show/sport');
    }

    /*
    *  九月运动会--证书
    */
    public function docertificate(){
        $this->in_user();
        $uid = $this->uid;
        $drawTotal = common::request('drawTotal', 'G','');  //项目完成总数

        if(!$uid)
        {
            common::tips('请先登录');
            exit;
        }

        //获得称号
        $designation = '';
        if($drawTotal >= 1 && $drawTotal <= 3){
            $designation = '运动小能手';
        }elseif($drawTotal >= 4 && $drawTotal <= 6){
            $designation = '运动小达人';
        }elseif($drawTotal >= 7 && $drawTotal <= 8){
            $designation = '运动小马达';
        }

        //查询用户信息
        $nickName = $this->db->getOne("select nickname from r_user where uid = {$uid}");

        $result['proCount'] = $drawTotal;
        $result['nickName'] = $nickName;
        $result['designation'] = $designation;
        $result['date'] = date('Y.m.d');

        $this->view->assign('result', $result);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/certificate');
    }

    /*
    *  九月运动会--项目
    */
    public function dosport(){
        $this->in_user();
        $uid = $this->uid;
        if(!$uid)
        {
            common::tips('请先登录');
            exit;
        }
        $startime = strtotime('2016-09-09 00:00:00');
        $endtime = strtotime('2016-09-13 23:59:59');
        $maxMileage=$sumMileage=$sumRunDays=$maxCalorie=$sumCalorie = 0;
        if(time() >= $startime)
        {
            //用户报名时间
            $addTime = $this->db->getOne("select add_time from r_sports_september where acttype = 1 and uid = {$uid}");
            $unixtime = date('Ymd', $addTime);
            //单次最大里程
            $maxMileage = $this->db->getOne("select max(mileage) from r_data where overSpeed = 0 and is_delete = 0 and uid = {$uid} and (updatetime between {$addTime} and {$endtime})");
            //累计里程
            $sumMileage = $this->db->getOne("select sum(mileage) from r_data where overSpeed = 0 and is_delete = 0 and uid = {$uid} and (updatetime between {$addTime} and {$endtime})");
            //累计跑步天数
            $sumRunDays = $this->db->getOne("select count(1) from r_data_day where uid = {$uid} and (date between '{$unixtime}' and '20160913')");
            //单次消耗最大卡路里
            $maxCalorie = $this->db->getOne("select max(calorie) from r_data  where overSpeed = 0 and is_delete = 0 and uid = {$uid} and (updatetime between {$addTime} and {$endtime})");
            //累计消耗卡路里
            $sumCalorie = $this->db->getOne("select sum(calorie) from r_data  where overSpeed = 0 and is_delete = 0 and uid = {$uid} and (updatetime between {$addTime} and {$endtime})");
        }

        $projectInfo = array(
            'maxMileage' => $maxMileage,
            'sumMileage' => $sumMileage,
            'sumRunDays' => $sumRunDays,
            'maxCalorie' => $maxCalorie,
            'sumCalorie' => $sumCalorie
        );

        //已抽奖次数
        $drawCount = $this->db->getOne("select draw_count from r_sports_september where acttype = 1 and uid = {$uid}");
        empty($drawCount) && $drawCount = 0;

        //计算总抽奖次数=项目完成个数
        $drawTotal = 0;
        if(intval($maxMileage) >=3 && intval($maxMileage) <10){
            $drawTotal += 1;
        }elseif(intval($maxMileage) >=10){
            $drawTotal += 2;
        }
        if(intval($sumMileage) >= 15){
            $drawTotal += 1;
        }
        if(intval($sumRunDays) == 2){
            $drawTotal += 1;
        }elseif(intval($sumRunDays) == 3){
            $drawTotal += 2;
        }elseif(intval($sumRunDays) >= 4){
            $drawTotal += 3;
        }
        if(intval($maxCalorie) >= 500){
            $drawTotal += 1;
        }
        if(intval($sumCalorie) >= 1000){
            $drawTotal += 1;
        }
        //剩余抽奖次数
        $drawRemain = $drawTotal - $drawCount;

        //计算是否可生成证书
        $isCertificate = 0;
        if(time() >= $endtime){
            $isCertificate = 1;
        }elseif($maxMileage >=10 && $sumRunDays >=4 && $sumMileage >=15 && $maxCalorie >=500 && $sumCalorie >=1000){
            $isCertificate = 1;
        }

        $this->view->assign('endtime', $endtime);
        $this->view->assign('isCertificate', $isCertificate);
        $this->view->assign('drawTotal', $drawTotal);    //可抽奖总数
        $this->view->assign('drawCount', $drawCount);    //已抽次数
        $this->view->assign('drawRemain', $drawRemain);  //剩余次数
        $this->view->assign('projectInfo', $projectInfo);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/sport');
    }

    /*
    *  九月运动会--抽奖接口
    */
    public function doDraw(){
        $this->printResult = TRUE;
        $this->in_user();
        $uid = $this->uid;
        if(!$uid){
            common::tips('请先登录');
            exit;
        }
        //活动结束后不可以抽奖
        $endtime = strtotime('2016-09-13 23:59:59');
        if(time() > $endtime){
            $_ENV['error']->getErrors(2010);
            exit;
        }
        //奖品字典
        $prizeInfo = array(
            '0' => '换个姿势再来一次',
            '1' => 'Apple watch',
            '2' => '跑鞋',
            '3' => '压缩腿套',
            '4' => '虎扑跑步定制速干衣',
            '5' => '跑步书籍',
            '6' => '虎扑跑步定制记事本'
        );

        //抽奖概率基数
        $total = 10000;

        //查询每种奖品的剩余数量,并定义概率
        $apple = $shoe = $legWarmer = $clothes = $books = $notebook = 0;
        $prizeCount = $this->db->getAll("select * from r_running_prize_sep where acttype = 1");
        foreach ($prizeCount as $v) {
            $v['prize'] == 1 && $apple = $v['remain_count'] ? $v['count'] : 0;
            $v['prize'] == 2 && $shoe = $v['remain_count'] ? $v['count'] : 0;
            $v['prize'] == 3 && $legWarmer = $v['remain_count'] ? $v['count'] : 0;
            $v['prize'] == 4 && $clothes = $v['remain_count'] ? $v['count'] : 0;
            $v['prize'] == 5 && $books = $v['remain_count'] ? $v['count'] : 0;
            $v['prize'] == 6 && $notebook = $v['remain_count'] ? $v['count'] : 0;
        }
        //echo "<pre/>"; print_r($prizeCount); exit;
        //定义每种奖品对应的概率
        /*$apple = 0;   //apple watch
        $shoe = 0;    //跑鞋
        $legWarmer = floor(($legWarmer*$total)/100);   //压缩腿套
        $clothes = floor(($clothes*$total)/100);   //虎扑跑步定制速干衣
        $books = floor(($books*$total)/100);   //跑步书籍
        $notebook = floor(($notebook*$total)/100);   //虎扑跑步定制记事本
        $other = $total - $apple - $shoe - $legWarmer - $clothes - $books - $notebook;
        $result = array();*/
        $other = $total - $apple - $shoe - $legWarmer - $clothes - $books - $notebook;
        for($i=0; $i<$legWarmer; $i++){
            $result[] = 3;
        }
        for($j=0; $j<$clothes; $j++){
            $result[] = 4;
        }
        for($k=0; $k<$books; $k++){
            $result[] = 5;
        }
        for($m=0; $m<$notebook; $m++){
            $result[] = 6;
        }
        for($n=0; $n<$other; $n++){
            $result[] = 0;
        }

        shuffle($result);
        $getPrize['id'] = $result[array_rand($result)]; //所获奖品
        //查找该用户是否被指定获得奖品
        $isAppoint = $this->db->getOne("select specify_prize from r_sports_september where acttype = 1 and uid = {$uid}");
        //查询指定奖品剩余个数
        if(!empty($isAppoint)){
            $remainCount = $this->db->getOne("select remain_count from r_running_prize_sep where acttype = 1 and prize = {$isAppoint}");
            if($remainCount > 0){
                $getPrize['id'] = $isAppoint;
            }else{
                $getPrize['id'] = 0;
            }
            //将用户的指定奖品置空
            $this->db->update("update r_sports_september set specify_prize = DEFAULT where acttype = 1 and uid = {$uid}");
        }

        $getPrize['prizeName'] = $prizeInfo[$getPrize['id']];
        //如果所获奖品不为空，更改数据库对应奖品数量
        if($getPrize['id'] != 0){
            $this->db->update("update r_running_prize_sep set remain_count = remain_count-1 where prize = {$getPrize['id']}");
        }
        //增加一次已抽奖次数
        $this->db->update("update r_sports_september set draw_count = draw_count+1 where acttype = 1 and uid = {$uid}");

        $this->result['result'] = $getPrize;

        /*$this->view->assign('getPrize', $getPrize);   //所获奖品信息
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/sport');*/
    }

    /*
    *  九月运动会--中奖信息登记接口
    */
    public function dosaveWinning(){
        $this->printResult = TRUE;
        $this->in_user();
        $uid = $this->uid;
        $name = common::request('name', 'P','');
        $phone = common::request('phone', 'P','');
        $address = common::request('address', 'P','');
        $prize = common::request('prize', 'P','');
        $size = common::request('size', 'P','');
        if(!$uid){
            common::tips('请先登录');
            exit;
        }
        $acttype = 1;  //活动类型：跑步运动会
        $params = compact('uid', 'name', 'phone', 'address', 'prize', 'size', 'acttype');
        $wid = $this->db->insertRowTable('r_winning_info', $params);
        $this->result['result']['wid'] = $wid;
    }

    /*
    *  中秋吃货大作战--首页
    */
    public function domidAutumn(){
        $this->in_user();
        $uid = $this->uid;
        $isJoin = 0;
        if(!$uid){
            //网页端登录--irun.hupu.com/connect/login
            common::go('joggers://login', true);
        }elseif(!common::isInAppWebview()){
            $rUrl = "http://".$this->config['host'].'/show/midShare';   //填写分享页
        }else{
            //查看用户是否已参与活动
            $isJoin = $this->db->getOne("select count(1) from r_sports_september where acttype = 2 and uid = {$uid}");
            $rUrl = "http://".$this->config['host'].'/show/midTask';
            //$rUrl = 'index.php?c=show&a=midTask';
            if($isJoin == 0){
                $rUrl = "http://".$this->config['host'].'/show/joinFoodie';
            }
        }

        $this->view->assign('rUrl', $rUrl);
        $this->view->assign('isJoin', $isJoin);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/mid-autumn');
    }

    /*
    *  中秋吃货大作战--参与活动接口
    */
    public function dojoinFoodie(){
        $this->in_user();
        $uid = $this->uid;

        if(!$uid)
        {
            common::tips('请先登录');
            exit;
        }

        $add_time = time();
        $acttype = 2;  //活动类型：跑步运动会
        $params = compact('uid', 'add_time', 'acttype');

        $this->db->insertRowTable('r_sports_september', $params);

        common::go("http://".$this->config['host'].'/show/midTask');
    }

    /*
    *  中秋吃货大作战--任务抽奖页面
    */
    public function domidGift(){
        $this->in_user();
        $uid = $this->uid;
        if(!$uid)
        {
            common::tips('请先登录');
            exit;
        }
        $startime = strtotime('2016-09-14 00:00:00');
        $endtime = strtotime('2016-09-17 23:59:59');
        $sumRunDays=$maxCalorie=$sumCalorie = 0;
        if(time() >= $startime)
        {
            //用户报名时间
            $addTime = $this->db->getOne("select add_time from r_sports_september where acttype = 2 and uid = {$uid}");
            $unixtime = date('Ymd', $addTime);
            //累计跑步天数
            $sumRunDays = $this->db->getOne("select count(1) from r_data_day where uid = {$uid} and (date between '{$unixtime}' and '20160917')");
            //单次消耗最大卡路里
            $maxCalorie = $this->db->getOne("select max(calorie) from r_data where overSpeed = 0 and is_delete = 0 and uid = {$uid} and (updatetime between {$addTime} and {$endtime})");
            //累计消耗卡路里
            $sumCalorie = $this->db->getOne("select sum(calorie) from r_data where overSpeed = 0 and is_delete = 0 and uid = {$uid} and (updatetime between {$addTime} and {$endtime})");
        }

        //已抽奖次数
        $drawCount = $this->db->getOne("select draw_count from r_sports_september where acttype = 2 and uid = {$uid}");
        empty($drawCount) && $drawCount = 0;

        //计算总抽奖次数=项目完成个数+分享次数
        $drawTotal = $this->db->getOne("select share_count from r_sports_september where acttype = 2 and uid = {$uid}");
        if(intval($sumRunDays) >= 2 && intval($sumRunDays) < 4){
            $drawTotal += 1;
        }elseif(intval($sumRunDays) >= 4){
            $drawTotal += 2;
        }
        if(intval($maxCalorie) >= 500){
            $drawTotal += 1;
        }
        if(intval($sumCalorie) >= 800 && intval($sumCalorie) < 1200){
            $drawTotal += 1;
        }elseif(intval($sumCalorie) >= 1200 && intval($sumCalorie) < 1800) {
            $drawTotal += 2;
        }elseif(intval($sumCalorie) >= 1800 && intval($sumCalorie) < 2500) {
            $drawTotal += 3;
        }elseif(intval($sumCalorie) >= 2500) {
            $drawTotal += 4;
        }

        //剩余抽奖次数
        $drawRemain = $drawTotal - $drawCount;

        $boxids = $this->redisCache->smembers(REDIS_PREFIX . 'drawStatus_' . $uid);

        $this->view->assign('boxids', $boxids);    //已抽奖的位置信息
        $this->view->assign('drawTotal', $drawTotal);    //可抽奖总数
        $this->view->assign('drawCount', $drawCount);    //已抽次数
        $this->view->assign('drawRemain', $drawRemain);  //剩余次数
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/mid-autumn_gift');
    }

    /*
    *  中秋吃货大作战--任务
    */
    public function domidTask(){
        $this->in_user();
        $uid = $this->uid;
        if(!$uid)
        {
            common::tips('请先登录');
            exit;
        }
        $startime = strtotime('2016-09-14 00:00:00');
        $endtime = strtotime('2016-09-17 23:59:59');
        $sumRunDays=$maxCalorie=$sumCalorie = 0;
        if(time() >= $startime)
        {
            //用户报名时间
            $addTime = $this->db->getOne("select add_time from r_sports_september where acttype = 2 and uid = {$uid}");
            $unixtime = date('Ymd', $addTime);
            //累计跑步天数
            $sumRunDays = $this->db->getOne("select count(1) from r_data_day where uid = {$uid} and (date between '{$unixtime}' and '20160917')");
            //单次消耗最大卡路里
            $maxCalorie = $this->db->getOne("select max(calorie) from r_data  where overSpeed = 0 and is_delete = 0 and uid = {$uid} and (updatetime between {$addTime} and {$endtime})");
            //累计消耗卡路里
            $sumCalorie = $this->db->getOne("select sum(calorie) from r_data  where overSpeed = 0 and is_delete = 0 and uid = {$uid} and (updatetime between {$addTime} and {$endtime})");
        }

        $projectInfo = array(
            'sumRunDays' => $sumRunDays,
            'maxCalorie' => $maxCalorie,
            'sumCalorie' => $sumCalorie
        );
        //已抽奖次数
        $drawCount = $this->db->getOne("select draw_count from r_sports_september where acttype = 2 and uid = {$uid}");
        empty($drawCount) && $drawCount = 0;

        //计算总抽奖次数=项目完成个数+分享次数
        $drawTotal = $this->db->getOne("select share_count from r_sports_september where acttype = 2 and uid = {$uid}");
        if(intval($sumRunDays) >= 2 && intval($sumRunDays) < 4){
            $drawTotal += 1;
        }elseif(intval($sumRunDays) >= 4){
            $drawTotal += 2;
        }
        if(intval($maxCalorie) >= 500){
            $drawTotal += 1;
        }
        if(intval($sumCalorie) >= 800 && intval($sumCalorie) < 1200){
            $drawTotal += 1;
        }elseif(intval($sumCalorie) >= 1200 && intval($sumCalorie) < 1800) {
            $drawTotal += 2;
        }elseif(intval($sumCalorie) >= 1800 && intval($sumCalorie) < 2500) {
            $drawTotal += 3;
        }elseif(intval($sumCalorie) >= 2500) {
            $drawTotal += 4;
        }

        //剩余抽奖次数
        $drawRemain = $drawTotal - $drawCount;

        $this->view->assign('drawTotal', $drawTotal);    //可抽奖总数
        $this->view->assign('drawCount', $drawCount);    //已抽次数
        $this->view->assign('drawRemain', $drawRemain);  //剩余次数
        $this->view->assign('projectInfo', $projectInfo);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/mid-autumn-task');
    }

    /*
    *  中秋吃货大作战--分享
    */
    public function domidShare(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/mid-autumn_share');
    }

    /*
    *  中秋吃货大作战--分享接口(用于增加抽奖次数)
    */
    public function domidAddDraw(){
        $this->in_user();
        $uid = $this->uid;
        if(!$uid)
        {
            common::tips('请先登录');
            exit;
        }
        //判断当天是否已分享
        $time = date("Y-m-d");
        $isShare = $this->redisCache->get(REDIS_PREFIX . 'isShare_' . $uid . $time);
        if(!$isShare)
        {
            //分享次数加一
            $this->db->update("update r_sports_september set share_count = share_count+1 where acttype = 2 and uid = {$uid}");
            $this->redisCache->set(REDIS_PREFIX . 'isShare_' . $uid . $time, 1);
            $this->redisCache->expire(REDIS_PREFIX . 'isShare_' . $uid . $time, 86400);
        }
    }

    /*
    *  中秋吃货大作战--抽奖接口
    */
    public function dofoodieDraw(){
        $this->printResult = TRUE;
        $this->in_user();
        $uid = $this->uid;
        $boxid = common::request('boxid','P');
        if(!$uid){
            common::tips('请先登录');
            exit;
        }

        //活动结束后不可以抽奖
        $endtime = strtotime('2016-09-17 23:59:59');
        if(time() > $endtime){
            $_ENV['error']->getErrors(2010);
            exit;
        }

        $this->redisCache->sadd(REDIS_PREFIX . 'drawStatus_' . $uid, $boxid);

        //奖品字典
        $prizeInfo = array(
            '0' => '换个姿势再来一次',
            '7' => '稻香村月饼礼盒',
            '8' => '哈根达斯200元现金卡',
            '9' => '哈根达斯100元现金卡',
            '10' => '10元话费'
        );

        //抽奖概率基数
        $total = 10000;

        //查询每种奖品的剩余数量,并定义概率
        $gitBox = $haagenTwo = $haagenOne = $phoneCharge = 0;
        $prizeCount = $this->db->getAll("select * from r_running_prize_sep where acttype = 2");
        foreach ($prizeCount as $v) {
            $v['prize'] == 7 && $gitBox = $v['remain_count'] ? $v['count'] : 0;
            $v['prize'] == 8 && $haagenTwo = $v['remain_count'] ? $v['count'] : 0;
            $v['prize'] == 9 && $haagenOne = $v['remain_count'] ? $v['count'] : 0;
            $v['prize'] == 10 && $phoneCharge = $v['remain_count'] ? $v['count'] : 0;
        }

        $other = $total - $gitBox - $haagenTwo - $haagenOne - $phoneCharge;
        for($i=0; $i<$gitBox; $i++){
            $result[] = 7;
        }
        for($j=0; $j<$haagenTwo; $j++){
            $result[] = 8;
        }
        for($k=0; $k<$haagenOne; $k++){
            $result[] = 9;
        }
        for($m=0; $m<$phoneCharge; $m++){
            $result[] = 10;
        }
        for($n=0; $n<$other; $n++){
            $result[] = 0;
        }

        shuffle($result);
        $getPrize['id'] = $result[array_rand($result)]; //所获奖品

        //查找该用户是否被指定获得奖品
        $isAppoint = $this->db->getOne("select specify_prize from r_sports_september where acttype = 2 and uid = {$uid}");
        //查询指定奖品剩余个数
        if(!empty($isAppoint)){
            $remainCount = $this->db->getOne("select remain_count from r_running_prize_sep where acttype = 2 and prize = {$isAppoint}");
            if($remainCount > 0){
                $getPrize['id'] = $isAppoint;
            }else{
                $getPrize['id'] = 0;
            }
            //将用户的指定奖品置空
            $this->db->update("update r_sports_september set specify_prize = DEFAULT where acttype = 2 and uid = {$uid}");
        }

        $getPrize['prizeName'] = $prizeInfo[$getPrize['id']];
        //如果所获奖品不为空，更改数据库对应奖品数量
        if($getPrize['id'] != 0){
            $this->db->update("update r_running_prize_sep set remain_count = remain_count-1 where prize = {$getPrize['id']}");
            //奖品id缓存留给登记用
            $this->redisCache->hset(REDIS_PREFIX . 'prizeId_' . $uid, 'prize', $getPrize['id']);
        }
        //增加一次已抽奖次数
        $this->db->update("update r_sports_september set draw_count = draw_count+1 where acttype = 2 and uid = {$uid}");

        $this->result['result'] = $getPrize;
    }

    /*
    *  中秋吃货大作战--中奖信息登记接口
    */
    public function dosavefoodie(){
        $this->printResult = TRUE;
        $this->in_user();
        $uid = $this->uid;
        $name = common::request('name', 'P','');
        $phone = common::request('phone', 'P','');
        $address = common::request('address', 'P','');

        $prize = $this->redisCache->hget(REDIS_PREFIX . 'prizeId_' . $uid, 'prize');
        if(!$uid){
            common::tips('请先登录');
            exit;
        }
        if(!common::checkPhone($phone)){
            $_ENV['error']->getErrors(3008);
            exit;
        }
        $acttype = 2;  //活动类型：跑步运动会
        $params = compact('uid', 'name', 'phone', 'address', 'prize', 'acttype');
        $wid = $this->db->insertRowTable('r_winning_info', $params);
        $this->result['result']['wid'] = $wid;
    }

    /*
    *  虎扑跑步装备节--首页
    */
    public function doEquipmentHome(){
        $this->in_user();
        $uid = $this->uid;

        if(!common::isInAppWebview()){
            common::go("http://".$this->config['host'].'/show/EquipmentShare');    //填写分享页
        }
        if(!$uid){
            //网页端登录--irun.hupu.com/connect/login
            common::go('joggers://login', true);
        }else{
            //查看用户是否已参与活动
            $isJoin = $this->db->getOne("select count(1) from r_sports_september where acttype = 3 and uid = {$uid}");

            if($isJoin == 0){
                //参与活动
                $add_time = time();
                $acttype = 3;  //活动类型：虎扑跑步装备节
                $params = compact('uid', 'add_time', 'acttype');

                $this->db->insertRowTable('r_sports_september', $params);
            }
        }

        //可抽奖的状态
        $time = date("Y-m-d");
        $beforeShare = $this->redisCache->get(REDIS_PREFIX . 'beforeShare_' . $uid . $time);
        $isShare = $this->redisCache->get(REDIS_PREFIX . 'isShare_' . $uid . $time);
        $afterShare = $this->redisCache->get(REDIS_PREFIX . 'afterShare_' . $uid . $time);
        $drawStatus = 0;   //抽奖亮，分享灰
        if(!empty($beforeShare) && empty($isShare) && empty($afterShare)){
           $drawStatus = 1;     //分享前已抽奖(抽奖灰，分享亮)
        }elseif(!empty($isShare) && empty($afterShare)){
            $drawStatus = 2;    //已分享(抽奖灰，分享变抽奖且亮)
        }elseif(!empty($afterShare)){
            $drawStatus = 3;    //分享后已抽奖(都灰)
        }

        //已经获得的字
        $hasReceived = $this->redisCache->hgetall(REDIS_PREFIX . 'getPrizes_' . $uid);
        $hasWords = array();
        $hasWordsNum = array('hu' => 0, 'pu' => 0, 'pao' => 0,'bu' => 0, 'zhuang' => 0, 'bei' => 0, 'jie' => 0);
        if(!empty($hasReceived)){
            $hasWords = array_count_values(array_values($hasReceived));
            foreach ($hasWords as $key => $value) {
                foreach ($hasWordsNum as $k => $v) {
                    $key == $k && $hasWordsNum[$k] = $hasWords[$key];
                }
            }
        }

        //已经获得的奖品
        $hasPrizes = $this->redisCache->hgetall(REDIS_PREFIX . 'hasPrizes_' . $uid);
        $hasPrizes = array_values($hasPrizes);
        //计算奖品是否可点
        $isPrizeClick = 0;
        count($hasWords) == 7 && !in_array(11, $hasPrizes) && $isPrizeClick = 1;  //ipone7可点击
        count(array_intersect(array('hu', 'pu', 'pao', 'bu'), array_keys($hasWords))) == 4 && !in_array(12, $hasPrizes) && $isPrizeClick = 2;  //鞋子可点击
        count(array_intersect(array('zhuang', 'bei', 'jie'), array_keys($hasWords))) == 3 && !in_array(13, $hasPrizes) && $isPrizeClick = 3;  //优惠券可点击
       
        $this->view->assign('isPrizeClick', $isPrizeClick);
        $this->view->assign('hasWords', $hasWordsNum);
        $this->view->assign('hasPrizes', $hasPrizes);
        $this->view->assign('drawStatus', $drawStatus);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/activity_equipment');
    }

    /*
    *  虎扑跑步装备节--更改抽奖状态接口
    */
    public function doisDraw(){
        $this->in_user();
        $uid = $this->uid;
        $operation = common::request('operation', 'P');
        if(!$uid)
        {
            common::tips('请先登录');
            exit;
        }

        $time = date("Y-m-d");
        if($operation == 1){
            //分享前抽字
            $beforeShare = $this->redisCache->get(REDIS_PREFIX . 'beforeShare_' . $uid . $time);
            if(!$beforeShare)
            {
                $this->redisCache->set(REDIS_PREFIX . 'beforeShare_' . $uid . $time, 1);
                $this->redisCache->expire(REDIS_PREFIX . 'beforeShare_' . $uid . $time, 86400);
            }
        }elseif($operation == 2)
        {
            //判断当天是否已分享
            $isShare = $this->redisCache->get(REDIS_PREFIX . 'isShare_' . $uid . $time);
            if(!$isShare)
            {
                //分享次数加一
                $this->db->update("update r_sports_september set share_count = share_count+1 where acttype = 3 and uid = {$uid}");
                $this->redisCache->set(REDIS_PREFIX . 'isShare_' . $uid . $time, 1);
                $this->redisCache->expire(REDIS_PREFIX . 'isShare_' . $uid . $time, 86400);
            }
        }elseif($operation == 3)
        {
            //分享后抽字
            $afterShare = $this->redisCache->get(REDIS_PREFIX . 'afterShare_' . $uid . $time);
            if(!$afterShare)
            {
                $this->redisCache->set(REDIS_PREFIX . 'afterShare_' . $uid . $time, 1);
                $this->redisCache->expire(REDIS_PREFIX . 'afterShare_' . $uid . $time, 86400);
            }
        }
    }

    /*
    *  虎扑跑步装备节--抽奖接口
    */
    public function doEquipmentDraw(){
        $this->printResult = TRUE;
        $this->in_user();
        $uid = $this->uid;
        if(!$uid){
            common::tips('请先登录');
            exit;
        }

        //活动结束后不可以抽奖
        $endtime = strtotime('2016-10-07 23:59:59');
        if(time() > $endtime){
            $_ENV['error']->getErrors(2010);
            exit;
        }

        //奖品字典
        $prizeInfo = array(
            '11' => 'hu',
            '12' => 'pu',
            '13' => 'pao',
            '14' => 'bu',
            '15' => 'zhuang',
            '16' => 'bei',
            '17' => 'jie'
        );

        //查询每种奖品的剩余数量,并定义概率
        $hu = 5;$pu = 7;$pao = 7;$bu = 6;$zhuang = 25;$bei = 25;$jie = 25;

        $diffArray = array('hu','pu','pao','bu');
        //已经获得的字
        $hasReceived = $this->redisCache->hgetall(REDIS_PREFIX . 'getPrizes_' . $uid);
        
        if(!empty($hasReceived)){
            $hasReceived = array_unique(array_values($hasReceived));
            //取得交集
            $intersection = array_intersect($diffArray, $hasReceived);
            if(count($intersection) == 3){
                //取差集
                $diff = array_diff($diffArray, $intersection);
                $prizeStr = array_values($diff)[0];
                $prizeStr == 'hu' && $hu = 0;
                $prizeStr == 'pu' && $pu = 0;
                $prizeStr == 'pao' && $pao = 0;
                $prizeStr == 'bu' && $bu = 0;
            }
        }
        //特殊处理
        if(in_array($uid, array('11108513', '12527037', '472593', '10970240', '31505'))){
            $hu = 1;$pu = 1;$pao = 1;$bu = 1;$zhuang = 0;$bei = 0;$jie = 0;
        }

        for($i=0; $i<$hu; $i++){
            $result[] = 11;
        }
        for($j=0; $j<$pu; $j++){
            $result[] = 12;
        }
        for($k=0; $k<$pao; $k++){
            $result[] = 13;
        }
        for($m=0; $m<$bu; $m++){
            $result[] = 14;
        }
        for($n=0; $n<$zhuang; $n++){
            $result[] = 15;
        }
        for($x=0; $x<$bei; $x++){
            $result[] = 16;
        }
        for($y=0; $y<$jie; $y++){
            $result[] = 17;
        }

        shuffle($result);
        $getPrize['id'] = $result[array_rand($result)]; //所获奖品

        //查找该用户是否被指定获得奖品
        $isAppoint = $this->db->getOne("select specify_prize from r_sports_september where acttype = 3 and uid = {$uid}");
        if(!empty($isAppoint)){
            $getPrize['id'] = $isAppoint;
            //将用户的指定奖品置空
            $this->db->update("update r_sports_september set specify_prize = DEFAULT where acttype = 3 and uid = {$uid}");
        }

        $getPrize['prizeName'] = $prizeInfo[$getPrize['id']];

        $date = time();
        $this->redisCache->hset(REDIS_PREFIX . 'getPrizes_' . $uid, $date, $getPrize['prizeName']);

        //增加一次已抽奖次数
        $this->db->update("update r_sports_september set draw_count = draw_count+1 where acttype = 3 and uid = {$uid}");

        $this->result['result'] = $getPrize;
    }

    /*
    *  虎扑跑步装备节--中奖信息登记接口
    */
    public function dosaveEquipment(){
        $this->printResult = TRUE;
        $this->in_user();
        $uid = $this->uid;
        $name = common::request('name', 'P','');
        $phone = common::request('phone', 'P','');
        $address = common::request('address', 'P','');
        $size = common::request('size', 'P','');
        $prize = common::request('prize', 'P','');

        if(!$uid){
            common::tips('请先登录');
            exit;
        }
        if(!empty($phone) && !common::checkPhone($phone)){
            $_ENV['error']->getErrors(3008);
            exit;
        }
        $acttype = 3;  //活动类型：跑步装备节
        $params = compact('uid', 'name', 'phone', 'address', 'size', 'prize', 'acttype');
        $wid = $this->db->insertRowTable('r_winning_info', $params);
        //标记用户中奖，并将对应奖品数量减一
        $date = time();
        $this->redisCache->hset(REDIS_PREFIX . 'hasPrizes_' . $uid, $date, $prize);
        $this->db->update("update r_running_prize_sep set remain_count = remain_count-1 where prize = {$prize}");

        $this->result['result']['wid'] = $wid;
    }


    /*
    *  闪购 flash-sales.html
    *  2016/09/21
    */
    public function doflashSales(){
        $this->dogroupondetail();
        exit;

        $this->in_user();
        $saleId = common::request('saleId','G');
        if(!common::isInAppWebview()){
            $saleInfo = $this->load('flashBuy')->getFlashBuyInfo($saleId);
            if($saleInfo && $saleInfo['weidian_link']){
                common::go($saleInfo['weidian_link']);
                exit;
            }
        }
        
        $this->view->assign('saleId',$saleId);
        $this->view->assign('uid',$this->uid);

        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/flash-sales');
    }
    public function doequipmentShare(){
       $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/equipment-share');
    }
    
    /*
     * 善珍合作页面
     */
    public function doshanzhen(){
        $this->in_user();
        $kouling = '立即报名';
        $bindStatus = 0;
        if($this->uid){
            $partner_mod = $this->load('partner');
            if(common::request('bind','G')){
                $partner_mod->bindByPartnerName(['uid'=>$this->uid,'partner_name'=>'shanzhen']);
                common::go('/show/shanzhen');
            }
            
            $userInfo = $this->load('client')->getUserInfo($this->uid);
            $bindInfo = $partner_mod->getUserInfo($this->uid,'shanzhen');
            $bindStatus = $bindInfo ? 1 : 0;
            if($bindInfo && $userInfo['max_mileage']>1){
                $kouling = '您的口令：虎扑跑步送健康';
            }elseif($bindInfo){
                $kouling = '请先完成一次一公里以上的跑步';
            }
        }
        
        $this->view->assign('kouling',$kouling);
        $this->view->assign('bindStatus',$bindStatus);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('uid',$this->uid);
        $this->view->display('show/shanzhen');
    }

    /*
    * 淘宝链接跳转
    */
    public function doGearGoto(){
        $url = common::request('url', 'G','');
        $this->view->assign('url',urldecode($url));
        $this->view->display('show/geargoto');
    }
    
    public function doGeartest(){
        $url = common::request('url', 'G','');
        $this->view->assign('url',urldecode($url));
        $this->view->display('show/equipment-test');
    }
    public function doHomeEquipment(){
        $this->in_user();
        $category = $this->load('gear')->getGearCategory();
        $bestGear = $this->load('gear')->getHomeBestGear();
        $newsList = $this->load('gear')->getHomeNewsList(1,1,3);
        $category = array_slice($category, 0,4);

        foreach ($bestGear as & $v) {
            $v['images'] = $v['images'][0];
        }

        $groupon = array();
        $groupon_top = $this->db->getOne('select id from r_flash_sales where type in (1,2) and status in(0,5)  and is_featured=1 order by update_time desc  limit 1');
        if(!empty($groupon_top)){
            $groupon = $this->load('gear')->getGrouponDetail($groupon_top);
        }

        $version = $this->load('gear')->getWebviewVersion();
        $category[] = array('logo'=>'/static/images/icon/all.png','catName'=>'全部','catId'=>0);
        foreach ($category as &$v) {
            $url = 'http://'.$this->config['host'] . '/show/gearList?catId='.$v['catId'].'&_track=homecategory&_trackValue='.$v['catId'];
            if($version>=3000) {
                $v['link'] = 'joggers://wv_gear_search/'.urlencode($url);
            }else{
                $v['link'] = $url;
            }
        }
        $this->view->assign('isNewVersion',$version>=3000?'true':'false');
        $this->view->assign('category',$category);
        $this->view->assign('bestGear',$bestGear);
        $this->view->assign('newsList',$newsList);
        $this->view->assign('groupon',$groupon);
        $this->view->assign('current_time',time());
        $this->view->assign('isabtest',common::getip()=='180.173.15.30'||ENVIRONMENT=='dev');
        $this->view->assign('shopcart',$this->load('gear')->checkshopcount($this->uid)>0?'2':'0');

        $this->view->display('show/equipment-home');
    }
    
    public function doRecommend(){
        $url = common::request('url', 'G','');
        $this->view->assign('url',urldecode($url));
        $this->view->display('show/recommend');
    }
    public function doGearNewsList(){
        $sort =(int)common::request("sort", 'G', '1');
        
        $this->view->assign('sort',$sort);
        $this->view->display('show/gearNewsList');
    }
    public function doGearList(){
        $this->in_user();
        $catId =(int)common::request("catId", 'G', '');
        $w  = urldecode(common::request("w", 'G', ''));
        $brand  = urldecode(common::request("brand", 'G', ''));
        $sex  = urldecode(common::request("sex", 'G', ''));
        $price  = urldecode(common::request("price", 'G', ''));
        $order  = urldecode(common::request("order", 'G', '1'));

        $categoryGroup = $this->load('gear')->getGearCategory();
        $brandGroup = $this->load('gear')->getGearBrand($catId);
        $version = $this->load('gear')->getWebviewVersion();

        $priceGroup = array(
            '0-100'=>'100元以下',
            '101-300'=>'101-300元',
            '301-500'=>'301-500元',
            '501-800'=>'501-800元',
            '801-1000'=>'801-1000元',
            '1001-1300'=>'1001-1300元',
            '1300'=>'1300元以上'
            );

        $this->view->assign('catId',$catId);
        $this->view->assign('w',$w);
        $this->view->assign('brand',$brand);
        $this->view->assign('sex',$sex);
        $this->view->assign('price',$price);
        $this->view->assign('order',$order);
        $this->view->assign('categoryGroup',$categoryGroup);
        $this->view->assign('priceGroup',$priceGroup);
        $this->view->assign('brandGroup',$brandGroup);
        $this->view->assign('shopcart',$this->load('gear')->checkshopcount($this->uid)>0?'2':'0');
        $this->view->assign('isNewVersion',$version>=3000?'true':'false');
        $this->view->display('show/gearList');
    }
    
    public function doequipment(){
        $this->in_user();
        $gearId =(int)common::request("gearId", 'G', 0);
        $token = common::request('token', 'P');
        $tokenArr = explode('-', $token);
        $tuid = intval($tokenArr[0])? :common::request('uid','R',0);

        $gearInfo = $this->load('gear')->getGearInfo($gearId);
        if($gearId < 1 || empty($gearInfo) || $gearInfo['isShow'] != 1)
        {
            header('Location: http://run.hupu.com/mobile?r=404');
            exit();
        }
        
        $gearInfo['shopName'] = common::detectShop($gearInfo['shopUrl']);
        $shoeAttr = common::$shoeAttr;
        $footType = array();
        $footCircle = array();

        if(!empty($gearInfo['footType']))
        {
            foreach ($gearInfo['footType'] as $v) {
                $footType[] = $shoeAttr['footType'][$v];
            }
        }

        $footType = implode(',',$footType);

        if(!empty($gearInfo['footCircle']))
        {
            foreach ($gearInfo['footCircle'] as $v) {
                $footCircle[] = $shoeAttr['footCircle'][$v];
            }
        }

        $footCircle = implode(',',$footCircle);
        $attrs = array( 'gender' => $gearInfo['gender'] == 1 ? '男' :'女',
                        'shoeCat' => empty($gearInfo['shoeCat'])? '' :$shoeAttr['shoeCat'][$gearInfo['shoeCat']],
                        'footType' => $footType,
                        'footCircle' => $footCircle,
                        //'feature' => $shoeAttr['feature'][$gearInfo['feature']],
                        'weight' => $gearInfo['weight'] .'克',
                        'publishTime' => date("Y-m-d", $gearInfo['publishTime'])
            );
        
        //获取评论
        $commentList = $this->load('gear')->getCommentList($gearId, 0,'next', 3);
        if($commentList)
        {
            foreach($commentList as $k => &$comment)
            {
                $comment['dateformat']=date("Y-m-d", $comment['addTime']);
                $image = json_decode($comment['image']);
                $thumbImg = json_decode($comment['thumbImg']);
                $comment['image'] = $image ;
                $comment['thumbImg'] = $thumbImg;
            }
        }
        //推荐装备
        $similarGear = $this->load('gear')->getSimilarGearRecommend($gearInfo['gearId'], $gearInfo['catId'], 5);

        //标签
        $styleList = array();
        if(!empty($gearInfo['goods_id'])) {
            $styleList = $this->db->getAll("select `name`,`pic`,`style_id` from r_gear_channelstyle  
            where goods_id = {$gearInfo['goods_id']} 
            and style_id in (select style_id from r_gear_channelsize where goods_id = {$gearInfo['goods_id']}
            and supplier_id in (select supplier_id from r_gear_channel where goods_id = {$gearInfo['goods_id']} and status=1 and merchant='淘宝'))  order by id asc");
        }

        //增加点击数
        $this->load('gear')->incrViewCounts($gearInfo['gearId']);
        $version = $this->load('gear')->getWebviewVersion();
        $firstImage = current($gearInfo['images']);

        $this->view->assign('uid',$tuid);
        $this->view->assign('gear', $gearInfo);
        $this->view->assign('gearId', $gearId);
        $this->view->assign('attrs', $attrs);
        $this->view->assign('commentList', $commentList);
        $this->view->assign('similarGear', $similarGear);
        $this->view->assign('staticHost', $this->config['img-host']);
        $this->view->assign('styleList',$styleList); 
        $this->view->assign('styleJson',json_encode($styleList));
        $this->view->assign('shartName',str_replace(array("\r", "\n", "'"), " ",$gearInfo['name']));
        $this->view->assign('shartDesc',str_replace(array("\r", "\n", "'"), " ",$gearInfo['shortDesc']));
        $this->view->assign('firstImage',$firstImage);
        $this->view->assign('shopcart',$this->load('gear')->checkshopcount($this->uid)>0?'2':'0');
        $this->view->assign('isNewVersion',$version>=3000?'true':'false');

        $this->view->display('show/equipment');
    }
    public function doyearEnd(){
        $uid = common::request('uid','G', 0, true);
        if (!$uid) {
            $this->in_user();
            $uid = $this->uid;
        } else {
            $uid = $this->alphaId->getNumber($uid);
        }
        if (!$uid) {
            header("Location: joggers://login",TRUE,302);exit;
        }
        $alphaId = $this->alphaId->getHash($uid);
        $this->view->assign('uid', $uid);
        $this->view->assign('alphaId', $alphaId);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/yearEnd');
    }
    public function donewYear(){
       $uid = common::request('uid','G', 0, true);
        if (!$uid) {
            $this->in_user();
            $uid = $this->uid;
        }

        $this->view->assign('uid', $uid);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/new-year');
    }
    public function doyearShare(){
        $uid = common::request('uid','G', 0, true);
        if (!$uid) {
            $this->in_user();
            $uid = $this->uid;
        } else {
            $uid = $this->alphaId->getNumber($uid);
        }
        if (!$uid) {
            echo '未登录';exit;
        }
        $alphaId = $this->alphaId->getHash($uid);
        $this->view->assign('uid', $uid);
        $this->view->assign('alphaId', $alphaId);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/year-share');
    }

    public function dogroupondetail(){
        $saleId = common::request('saleId', 'R', 0);
        $flashId = common::request('flashId', 'R', 0);
        $ua = '11'.$_SERVER['HTTP_USER_AGENT'];
        $isShare = strpos($ua,'Joggers') === false ? 'true' : 'false';

        if(!empty($saleId)){
            $flashId = $saleId;
        }
        if (!$flashId || !is_numeric($flashId)) {
            echo '错误的参数';
            exit;
        }
        $result = $this->load('gear')->getGrouponDetail($flashId);
        if (!$result||$result['status']==-5) {
            echo '没有查询到信息';
            exit;
        }

        //渲染海淘页面
        if($result['type']==4){
            $this->dohaitaodetail($result);
            exit;
        }
       
        $goods = array();
        $result['good_list'] = array();
        if(empty($result['shihuo_grouponid'])){
            $goods = $this->load('gear')->wrappergoodsinfo($result['id']);
            $result['good_list'] = $goods;
            $goods = $goods['childGoods'];
        }
        $this->in_user();
        $version = $this->load('gear')->getWebviewVersion();

        $this->view->assign('isNewVersion',$version>=3000?'true':'false');
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('groupon', $result);
        $this->view->assign('current_time', time());
        $this->view->assign('goods', json_encode($goods));
        $this->view->assign('isShare', $isShare);
        $this->view->assign('shopcart',$this->load('gear')->checkshopcount($this->uid)>0?'2':'0');
        $this->view->assign('mlink', urlencode("http://".$this->config['host']."/show/flashSales?saleId=". $result['id']));
        $this->view->display('show/groupon-detail');
    }

    public function dohaitaodetail($result){
        $this->in_user();
        $isHasCardId = 0;
        if(!empty($this->uid)) {
            $cardId = $this->load('gear')->getUserCardId($this->uid);
            $isHasCardId = !empty($cardId)?'1':'2';
        }
        $ua = '11'.$_SERVER['HTTP_USER_AGENT'];
        $isShare = strpos($ua,'Joggers') === false ? 'true' : 'false';

        $result['good_list'] = array();

        $goods = $this->load('gear')->wrappergoodsinfo($result['id']);
        $result['good_list'] = $goods;
        $childGoods = $goods['childGoods'];

        $haitao = $this->load('gear')->gethaitaodetail($result['shihuo_grouponid']);
        $result['images'] = json_decode($haitao['pictures']);
        $result['image'] = current($result['images']);
        $result['image_content'] = $haitao['memo'];
        $result['title'] = $haitao['title'];
        $result['low_price'] = $haitao['price'];
        $result['cost_price'] = $haitao['price'];
        $result['express_fee'] = $goods['product']['express_fee']+10;
        $result['size_info'] = array();
        $haitao['size_info'] = (array)json_decode($haitao['size_info']);
        foreach ($haitao['size_info'] as & $v) {
            $result['size_info'][] = (array)$v;
        }


        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('groupon', $result);
        $this->view->assign('current_time', time());
        $this->view->assign('goods', json_encode($childGoods));
        $this->view->assign('isShare', $isShare);
        $this->view->assign('shopcart',$this->load('gear')->checkshopcount($this->uid)>0?'2':'0');
        $this->view->assign('isHasCardId', $isHasCardId);
        $this->view->assign('mlink', urlencode("http://".$this->config['host']."/show/flashSales?saleId=". $result['id']));
        $this->view->display('show/haitao-detail');
    }

    public function dohaitaoZB(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/haitao-zb');
    }
    public function dovalentineS(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/valentineS');
    }
 
    public function dovalentineCard(){
        $this->in_user();
        $this->in_client();
        $uid = $this->uid;
        $userInfo = array(
            "userName" => '我',
            "mileage" => '',
            "addtime" => '',
        );
        
        if($uid){  //登录用户
            $userInfo['userName'] = $this->redis->hget(REDIS_PREFIX.'UserInfo_'.$uid, 'nickname');
            //查询最近一次跑步数据
            $sql = "SELECT mileage, addtime FROM r_data WHERE uid = {$uid} and overSpeed = 0 and is_delete = 0 ORDER BY addtime desc LIMIT 1";
            $runData = $this->db->getRow($sql);
        }else{   //游客
            $vid = $this->vid;
            $sql = "SELECT mileage, addtime FROM r_visitor_data WHERE vid = {$vid} and is_delete = 0 ORDER BY addtime desc LIMIT 1";
            $runData = $this->db->getRow($sql);
        }
        if($runData){
            if($runData['addtime'] < 1487143200){
                common::go("http://".$this->config['host'].'/show/valentineS');
                exit;
            }
            $userInfo['mileage'] = $runData['mileage'];
            $userInfo['addtime'] = date('d.m.Y', $runData['addtime']);
        }else{
            common::go("http://".$this->config['host'].'/show/valentineS');
            exit;
        }
        
        //二维码内容
        $codeStr = "http://".$this->config['host'].'/show/heartCode?userName='.$userInfo['userName'].'&mileage='.$userInfo['mileage'].'&addtime='.$userInfo['addtime'];
        $codeStr = base64_encode($codeStr);
        $codeValue = "http://".$this->config['host'].'/show/produceCode?code='.$codeStr;
        
        $this->view->assign('code', $codeValue);
        $this->view->assign('userInfo', $userInfo);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/valentine-card');
    }

    /**
    * 怦然心动二维码的内容
    */
    public function doheartCode(){
        $userName = common::request("userName", 'R');
        $mileage = common::request("mileage", 'R');
        $addtime = common::request("addtime", 'R');

        $this->view->assign('userName', $userName);
        $this->view->assign('mileage', $mileage);
        $this->view->assign('addtime', $addtime);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/valentine-share');
    }

    //生成二维码
    public function doproduceCode(){
        $code = common::request("code", 'R');
        $code = base64_decode($code);
        require FILE . 'lib/phpqrcode.php';
        QRcode::png($code, false, "L", 2, 1);
    }

    public function dohaitaoCardId(){
        $flashId =(int)common::request("flashId", 'G');
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->assign('flashId', $flashId);
        $this->view->display('show/haitao-cardId');
    }
    public function dogrouponList(){
        $this->in_user();
        $sort =(int)common::request("sort", 'G', '1');
        $this->view->assign('sort',$sort);
        $this->view->assign('current_time',time());
        $this->view->assign('shopcart',$this->load('gear')->checkshopcount($this->uid)>0?'2':'0');
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/groupon-list');
    }
    public function dogrouponApprove(){
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/groupon-approve');
    }
    public function doshoppingCart(){
        $this->in_user();
        if(empty($this->uid)){
            echo '<script>location.href = "joggers://login/"</script>';
            exit;
        }
        $cartList = $this->load('gear')->shopcartlist($this->uid);


        //print_r($cartList);

        $this->view->assign('cartList', $cartList);
        $this->view->assign('staticHost', "http://".$this->config['host']);
        $this->view->display('show/shoppingCart');
    }

    public function dogearNewsTj(){
        $this->view->display('show/gear_newstj');
    }
}
